echarts图表环形图设置默认一项为选中状态

mounted() {
    var chartDom = this.$refs.newEchartsRef;
    this.myChart = echarts.init(chartDom);
    let myChart = this.myChart; //解决echarts中this指向问题
    this.option && this.myChart.setOption(this.option);
    myChart.dispatchAction({ type: "highlight", seriesIndex: 0, dataIndex: 0 }); //设置默认选中高亮部分
    let index = 0;
    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,
      });
    });
  },

猜你喜欢

转载自blog.csdn.net/m0_70547044/article/details/133266418
今日推荐