echarts饼状图默认选中

echarts yekong 1184℃

数据可视化大屏项目开发中,需要让echarts饼状图默认选中最大的一个,我们可以通过dispatchAction来设置。

echarts饼状图默认选中

  let index = 1;//默认选中第二个
  myChart.dispatchAction({
    type: 'highlight',
    seriesIndex: 0,
    dataIndex: 1,//默认选中第二个
  });
  myChart.on('mouseover', function (e) {
    if (e.dataIndex != index) {
      myChart.dispatchAction({
        type: 'downplay',
        seriesIndex: 0,
        dataIndex: index,
      });
    }
  });
  myChart.on('mouseout', function (e) {
    index = e.dataIndex;
    myChart.dispatchAction({
      type: 'highlight',
      seriesIndex: 0,
      dataIndex: e.dataIndex,
    });
  });
喜欢 (1)