代码拉取完成,页面将自动刷新
同步操作将从 Ambit/echarts-for-vue 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
简体中文 | English
ECharts wrapper component for Vue 3 and 2
npm i -S echarts-for-vue
import { createApp, h } from 'vue';
import echarts from 'echarts';
import { plugin } from 'echarts-for-vue';
const app = createApp({ /*...*/ });
app.use(plugin, { echarts, h }); // use as a plugin
<template>
<ECharts ref="chart" :option="option" />
</template>
<script>
import echarts from 'echarts';
import { h } from 'vue';
import { createComponent } from 'echarts-for-vue';
export default {
components: {
ECharts: createComponent({ echarts, h }), // use as a component
},
data() {
return {
option: { /*...*/ },
};
},
methods: {
doSomething() {
this.$refs.chart.inst.getWidth(); // call the method of ECharts instance
},
},
}
</script>
import Vue from 'vue';
import echarts from 'echarts';
import { plugin } from 'echarts-for-vue';
Vue.use(plugin, { echarts }); // use as a plugin
<template>
<ECharts ref="chart" :option="option" />
</template>
<script>
import echarts from 'echarts';
import { createComponent } from 'echarts-for-vue';
export default {
components: {
ECharts: createComponent({ echarts }), // use as a component
},
data() {
return {
option: { /*...*/ },
};
},
methods: {
doSomething() {
this.$refs.chart.inst.getWidth(); // call the method of ECharts instance
},
},
}
</script>
Definition | Return | Explanation |
---|---|---|
createComponent (initialOptions: object): object |
Component definition object | Create a component |
plugin (app: Vue, initialOptions: object): void |
The installation method of plugin |
Property | Type | Default | Optional | Explanation |
---|---|---|---|---|
echarts | object | The global object of ECharts library | ||
h | function | ✔ | The method createElement of Vue (Required for Vue 3) |
|
ResizeObserver | function | window.ResizeObserver | ✔ | When the global ResizeObserver doesn't exist, the polyfill provides support |
name | string | "ECharts" | ✔ | The registered name of the component |
Name | Type | ReadOnly | Explanation |
---|---|---|---|
inst | object | ✔ | ECharts instance |
Name | Type | Default | Reactive | Explanation |
---|---|---|---|---|
initTheme | object | string | The parameter theme of echarts.init method, see
|
||
initOpts | string | The parameter opts of echarts.init method, see
|
||
loading | boolean | false | ✔ | Shows loading animation |
loadingType | string | "default" | The parameter type of ECharts instance method showLoading , see
|
|
loadingOpts | object | The parameter opts of ECharts instance method showLoading , see
|
||
option | object | ✔ | The parameter option of ECharts instance method setOption , see
|
|
setOptionOpts | object | The parameter opts of ECharts instance method setOption , see
|
||
events | Arguments[] | An array element is the arguments of ECharts instance method on , see
|
||
autoResize | boolean | true | ✔ | Auto resize (Based on ResizeObserver , forward compatibility via polyfill) |
Beyond the props
above, the remaining properties are passed to the outer div
, such as style
, class
or onclick
Definition | Explanation |
---|---|
setOption (option: object, opts: object): void |
Call the method setOption of ECharts instance, see
|
resize (): void |
Resize chart (Based on the size of outer div) |
addResizeListener (): void |
Add "resize" listener |
removeResizeListener (): void |
Remove "resize" listener |
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。