Echarts 环形饼状图 实例效果

echarts yekong 184℃

Echarts 环形饼状图 实例效果

    drawLine() {
      var that = this
      window.addEventListener('resize', this.drawLine)
      let myChart = this.$echarts.init(this.$refs.echarts)
      var legends = ['深松', '深翻', '植保', '粉碎', '施肥'];
      var colors = ['rgba(2, 118, 232, 1)', 'rgba(243, 113, 63, 1)', 'rgba(1, 172, 145, 1)', 'rgba(214, 159, 39, 1)'];
      var data = [{
        name: '深松',
        value: 10
      },
        {
          name: '深翻',
          value: 8
        },
        {
          name: '植保',
          value: 7
        },
        {
          name: '粉碎',
          value: 7
        },
        {
          name: '施肥',
          value: 7
        }
      ];
      var option = {
        color: colors,
        legend: {
          orient: 'vertical',
          top: '20%',
          icon: "circle",
          right: "15%",
          itemGap: 10,
          itemWidth: 20,
          height: '100%',
          itemHeight: 12,
          formatter: function (name) {
            var data = option.series[0].data;
            var total = 0;
            var tarValue;
            for (var i = 0; i < data.length; i++) {
              total += data[i].value;
              if (data[i].name == name) {
                tarValue = data[i].value;
              }
            }
            var v = tarValue;
            var p = Math.round(((tarValue / total) * 100));
            return `${name}  ${p}%`;
          },
          textStyle: {
            color: "#fff",
            fontSize: 14
          },
          data: legends,
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        series: [
          {
            name: '作业类型对比',
            type: 'pie',
            radius: ['20%', '70%'],
            center: ['35%', '50%'],
            label: {
              show: false
            },
            labelLine: {
              length: 1,
              length2: 20,
              show: false
            },
            data: data
          },
          {
            stack: 'a',
            type: 'pie',
            center: ['35%', '50%'],
            radius: ['20%', '35%'],
            roseType: 'area',
            zlevel: 10,
            hoverAnimation: false,
            tooltip: {
              show: false
            },
            labelLine: {
              show: false,
              length: 1,
              length2: 20
            },
            data: [{
              name: '',
              value: 0,
              itemStyle: {
                normal: {
                  color: "rgba(0,0,0,0.3)"
                }
              }
            }]
          }
        ]
      };
      myChart.clear()
      myChart.resize()
      myChart.setOption(option)
    },
喜欢 (0)