关键API:dispatchAction
实现代码:
// tooltip轮播
autoTooltip = () => {
const dataLength = this.props.mapData.length; // 地图数据
const _this = this;
timer = setTimeout(function() {
// 取消高亮
mychart.dispatchAction({
type: 'downplay',
seriesIndex: 0
})
// 高亮
mychart.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: index
});
mychart.dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: index
});
index++;
if(index >= dataLength) {
index = 0;
}
_this.autoTooltip();
}, 2000);
}
官方属性介绍
echarts官方地址:https://echarts.apache.org/zh/api.html#action