echarts在vue中实现自动触发的效果

3,755 阅读1分钟


var app = {

currentIndex: -1
}

methods:{

getTime () {

this.timer = setInterval(() => {

var dataLen = this.option.series[0].data.length
// 取消之前高亮的图形
this.myChart.dispatchAction({
type: 'downplay',
seriesIndex: 0,
dataIndex: app.currentIndex
})
app.currentIndex = (app.currentIndex + 1) % dataLen
// 高亮当前图形
this.myChart.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: app.currentIndex
})
// 显示 tooltip
this.myChart.dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: app.currentIndex
})
}, 1000)
}

}