xnpm install -S @xm/vue-charts
import Vue from 'vue'
import Chart,{ VChart, BarChart, LineChart, AreaChart, PieChart, MapChart, registerTheme, registerMap } from '@xm/vue-charts'
Vue.use(Chart) // 整体引入组件
Vue.use(BarChart)-
initOptionsUsed to initialize ECharts instance.
-
themeThe theme used for current ECharts instance.
-
optionsUsed to update data for ECharts instance. Modifying this prop will trigger ECharts'
setOptionmethod.If you mutate the data bound to
optionswhile retaining the object reference,setOptionwill be called withnotMerge: false. Otherwise, if you bind a new object tooptions,setOptionwill be called withnotMerge: true.For example, if we have the following template:
<v-chart :options="data" />
Then:
this.data = newObject // setOption(this.options, true) this.data.title.text = 'Trends' // setOption(this.options, false)
-
groupThis prop is automatically bound to the same prop of the ECharts instance.
-
autoresize(default:false)This prop indicates ECharts instance should be resized automatically whenever its root is resized.
-
manual-update(default:false)For performance critical scenarios (having a large dataset) we'd better bypass Vue's reactivity system for
optionsprop. By specifyingmanual-updateprop withtrueand not providingoptionsprop, the dataset won't be watched any more. After doing so, you need to retrieve the component instance withrefand manually callmergeOptionsmethod to update the chart.
-
width[readonly]Used to retrieve the current width of the ECharts instance.
-
height[readonly]Used to retrieve the current height of the ECharts instance.
-
computedOptions[readonly]Used to retrive the actual options calculated by ECharts after updating
options.
-
mergeOptions(usesetOptionin ECharts under the hood)Provides a better method name to describe the actual behavior of
setOption. -
appendData -
resize -
dispatchAction -
showLoading -
hideLoading -
convertToPixel -
convertFromPixel -
containPixel -
getDataURL -
getConnectedDataURL -
clear -
dispose
connectdisconnectregisterMapregisterThemegraphic.clipPointsByRectgraphic.clipRectByRect
Vue-ECharts support the following events:
legendselectchangedlegendselectedlegendunselectedlegendscrolldatazoomdatarangeselectedtimelinechangedtimelineplaychangedrestoredataviewchangedmagictypechangedgeoselectchangedgeoselectedgeounselectedpieselectchangedpieselectedpieunselectedmapselectchangedmapselectedmapunselectedaxisareaselectedfocusnodeadjacencyunfocusnodeadjacencybrushbrushselectedrenderedfinished- Mouse events
clickdblclickmouseovermouseoutmousemovemousedownmouseupglobaloutcontextmenu
- ZRender events (since v4.1.0)
clickmousedownmouseupmousewheeldblclickcontextmenu
For further details, see ECharts' API documentation.
$ npm i
$ npm run serveOpen http://localhost:8080/ to see the demo.