Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

echarts-for-vue

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

echarts-for-vue

ECharts wrapper component for Vue 3, 2 and TypeScript

  • 1.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

简体中文 | English

ECharts For Vue  Version

📊📈 ECharts wrapper component for Vue 3, 2 and TypeScript

Features

  1. Support for Vue 3 and 2;
  2. Support auto resize;
  3. Conform to the habits of Vue and ECharts users;
  4. Provide pure function API, no side effects;
  5. Lightweight encapsulation, easy to use;

Install

npm i -S echarts-for-vue

Usage

  1. Vue 3
import { createApp, h } from 'vue';
import { plugin } from 'echarts-for-vue';
import * as echarts from 'echarts';

const app = createApp({ /*...*/ });
app.use(plugin, { echarts, h });                        // use as a plugin
<template>
    <ECharts ref="chart" :option="option" />
</template>

<script>
    import { createComponent } from 'echarts-for-vue';
    import * as echarts from 'echarts';
    import { h } from 'vue';

    export default {
        components: {
            ECharts: createComponent({ echarts, h }),   // use as a component
        },
        data: () => ({
            option: { /*...*/ },
        }),
        methods: {
            doSomething() {
                this.$refs.chart.inst.getWidth();       // call the method of ECharts instance
            },
        },
    }
</script>
  1. Vue 2
import Vue from 'vue';
import { plugin } from 'echarts-for-vue';
import * as echarts from 'echarts';

Vue.use(plugin, { echarts });                           // use as a plugin
<template>
    <ECharts ref="chart" :option="option" />
</template>

<script>
    import { createComponent } from 'echarts-for-vue';
    import * as echarts from 'echarts';

    export default {
        components: {
            ECharts: createComponent({ echarts }),      // use as a component
        },
        data: () => ({
            option: { /*...*/ },
        }),
        methods: {
            doSomething() {
                this.$refs.chart.inst.getWidth();       // call the method of ECharts instance
            },
        },
    }
</script>
  1. More examples
  2. Online demo

Global API

DefinitionReturnDescription
createComponent(options: Options): objectComponent definition objectCreate a component
plugin(app: Vue, options: Options): voidThe installation method of plugin

Options

PropertyTypeDefaultOptionalDescription
echartstypeof echartsThe global object of ECharts library
hFunctionThe method createElement of Vue (Required for Vue 3)
ResizeObservertypeof ResizeObserverwindow.ResizeObserverWhen the global ResizeObserver doesn't exist, the polyfill provides support
namestring"ECharts"The registered name of the component
deepWatchOptionbooleantruedeep watch prop "option"

Instance Properties

NameTypeReadOnlyDescription
instEChartsECharts instance

props

NameTypeDefaultReactiveDescription
initThemeobject | stringThe parameter theme of echarts.init method, see
initOptsobjectThe parameter opts of echarts.init method, see
loadingbooleanfalseShows loading animation
loadingTypestring"default"The parameter type of ECharts instance method showLoading, see
loadingOptsEChartsLoadingOptionThe parameter opts of ECharts instance method showLoading, see
optionEChartOptionThe parameter option of ECharts instance method setOption, see
optionOptsEChartsOptionConfigThe parameter opts of ECharts instance method setOption, see
eventsArguments[]An array element is the arguments of ECharts instance method on, see
autoResizebooleantrueAuto resize

Beyond the props above, the remaining properties are passed to the root element of the component, such as style, class or onclick

Events

NameDescription
resizeTrigger when chart is resized

methods

DefinitionDescription
setOption(option: EChartOption, opts?: EChartsOptionConfig): voidCall the method setOption of ECharts instance, see
resize(): voidResize chart (Based on the size of root element)
addResizeListener(): voidAdd "resize" listener
removeResizeListener(): voidRemove "resize" listener

Contact

  1. WeChat: cai_fanwei
  2. QQ: 854521460
  3. QQ Group: 663286147
  4. E-mail: ambit_tsai@qq.com

Keywords

FAQs

Package last updated on 08 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc