pieActive(myChart, option, data) {
let index = -1; //高亮所在下标
let dataLength = "";
let type = 0;
if (option.series.length > 1) {
option.series.forEach((item, index) => {
if (item.type == "bar") {
dataLength = option.series[index].data.length;
type = 1;
} else if (item.type == "surface") {
dataLength = data.length;
}
});
} else {
dataLength = option.series[0].data.length; // 当前饼图有多少个扇形
}
// 用定时器控制饼图高亮
let interval = setInterval(() => {
// 清除之前的高亮
myChart.dispatchAction({
type: "downplay",
seriesIndex: type,
dataIndex: index
});
index = (index + 1) % dataLength;
// 当前下标高亮
myChart.dispatchAction({
type: "showTip",
seriesIndex: type,
dataIndex: index
});
myChart.dispatchAction({
type: "highlight",
seriesIndex: type,
dataIndex: index
});
if (index > dataLength) {
index = 0;
}
}, 2000);
// this.activeInterval.push(interval)
},
echarts图表自动滚动代码
echarts图表自动滚动代码
扫描二维码,在手机上阅读
推荐阅读: