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});
});


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM