1.4.1 • Published 3 years ago

echarts-for-vue v1.4.1

Weekly downloads
243
License
Apache-2.0
Repository
github
Last release
3 years ago

简体中文 | 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
1.4.1

3 years ago

1.4.0

3 years ago

1.2.0

3 years ago

1.3.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago