版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_32768743/article/details/84030511
这个功能想要好久了,几次都没有机会上。
相关的issue: 希望提供 legend的反选按钮 #8837
相关的文档: EChart action
一個簡單到實現:
handleToggle () {
console.log('图例反选')
if (this.echart) {
const legends = this.data.columns
for (let i = 1; i < legends.length; i++) {
this.echart.dispatchAction({
type: 'legendToggleSelect',
// 图例名称
name: legends[i]
})
}
} else {
console.log('未获取echart实例')
}
}
關於在v-chart
中獲取echart
實例,找不到之前到文章了。:)
唉,一個簡單代碼
<ve-line
ref="chart"
></ve-line>
給一個chart到ref引用
this.$nextTick(() => {
this.echart = this.$refs.chart.echarts
})
在$nextTick
中獲取實例,不然可能獲取不到