this.rtecharts.setOption(option);
let _this = this;
let isSet = true; // 为了做判断:当鼠标移动上去的时候,自动高亮就被取消
let currentIndex = 0;
clearInterval(_this.startCharts);
this.rtecharts.on(“mouseover”, function (param) {
isSet = false;
clearInterval(_this.startCharts);
// 取消之前高亮的图形
_this.rtecharts.dispatchAction({
type: “downplay”,
seriesIndex: 0,
dataIndex: currentIndex,
});
// 高亮当前图形
_this.rtecharts.dispatchAction({
type: “highlight”,
seriesIndex: 0,
dataIndex: param.dataIndex,
});
currentIndex = param.dataIndex; // 把当前坐标变成当前高亮图形
// 显示 tooltip
_this.rtecharts.dispatchAction({
type: “showTip”,
seriesIndex: 0,
dataIndex: param.dataIndex,
});
});
// 3、自动高亮展示
let chartHover = function () {
let dataLen = option.series[0].data.length;
// 取消之前高亮的图形
_this.rtecharts.dispatchAction({
type: “downplay”,
seriesIndex: 0,
dataIndex: currentIndex,
});
currentIndex = (currentIndex + 1) % dataLen;
// 高亮当前图形
_this.rtecharts.dispatchAction({
type: “highlight”,
seriesIndex: 0,
dataIndex: currentIndex,
});
// 显示 tooltip
_this.rtecharts.dispatchAction({
type: “showTip”,
seriesIndex: 0,
dataIndex: currentIndex,
});
};
_this.startCharts = setInterval(chartHover, 2000);
// 4、鼠标移出之后,恢复自动高亮
this.rtecharts.on(“mouseout”, function (param) {
if (!isSet) {
clearInterval(_this.startCharts);
_this.startCharts = setInterval(chartHover, 2000);
isSet = true;
}
});
echarts 饼状图 轮播显示
最新推荐文章于 2024-10-10 17:15:55 发布