视频就不给大家演示了 大家看上一篇👆
来 上代码
clearInterval(mTimer);
let than = this.chart;
var app = {
currentIndex: -1,
};
let dataLen = 0;
if (mixChartData.series[0].data.length > 0 && typeof mixChartData.series[0].data != 'undefined') {
dataLen = mixChartData.series[0].data.length
}
var mTimer = setInterval( () => {
if(!this.isAutoChangeTooltip){
return;
}
// 取消之前高亮的图形
than.dispatchAction({
type: 'downplay',
seriesIndex: 0,
dataIndex: app.currentIndex
});
app.currentIndex = (app.currentIndex + 1) % dataLen;
// 高亮当前图形
than.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: app.currentIndex,
});
// 显示 tooltip
than.dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: app.currentIndex
});
}, 1500);
// 鼠标移入移出事件
this.chart.on('mouseover', (params)=> {
this.isAutoChangeTooltip = false
});
this.chart.on('mouseout', (params) =>{
this.isAutoChangeTooltip = true
});
基本就和上一篇没有大的区别
就是可以看到 我运用到echarts的事件
添加链接描述
大家可以点击这去官网看一下
就是这块就是事件的处理
所以我运用到鼠标移入移出的事件
看以上代码 首先我必须声明一个参数为true
我在走进这个计时器我要判断一下
if(!this.isAutoChangeTooltip){
return;
}
是不是true 好啦
完美 完美完美