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