// 图形初始化
initData(){
//tooltip自动播放
this.autoPlayToolTip()
this.addEvents()
}
// tooltip自动播放
autoPlayToolTip() {
// 防止多次添加轮播定时器,扰乱轮播节奏
if(this.timer) return
const that = this
this.timer = setInterval(() => {
if(that.index > 14) {
that.index = 0
}
that.chart.dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: that.index
})
that.index++
}, 3000)
},
// 清除轮播定时器
resetTimer(dataIndex) {
clearInterval(this.timer)
this.timer = null
this.index = dataIndex || 0
},
// 鼠标悬浮停止轮播 鼠标离开自动轮播
addEvents() {
const that = this
this.chart.on('mousemove', function (params) {
const { dataIndex } = params
that.resetTimer(dataIndex + 1)
})
this.chart.on('mouseout', function () {
that.autoPlayToolTip()
})
}
vue echarts图表提示气泡自动轮播
最新推荐文章于 2024-04-23 09:47:19 发布