echarts中饼图或环形图的高亮效果(点击高亮/默认某一条高亮)

let chooseIndex = 0;//默认选中高亮模块索引 现在是默认第一条


that.myChart = echarts.init(document.getElementById(that.indexAll.id));
that.myChart.clear();
that.myChart.setOption(_option);


//默认第一条高亮
that.myChart.dispatchAction({type: 'highlight',seriesIndex: 0,dataIndex: 0});

that.myChart.off('click');  //取消echarts点击多次触发
that.myChart.on('click',function(e){
// console.log(e)

if(e.dataIndex != chooseIndex){
//没用选中的取消高亮
that.myChart.dispatchAction({type: 'downplay', seriesIndex: 0, dataIndex: chooseIndex});
}
//选中某一条高亮
chooseIndex = e.dataIndex;
that.myChart.dispatchAction({type: 'highlight',seriesIndex: 0,dataIndex: e.dataIndex});
});
posted @ 2020-05-08 16:32  是闷闷啊  阅读(5151)  评论(0编辑  收藏  举报