【无标题】

3 篇文章 0 订阅

在这里插入图片描述


 <div class="bar-zoom" ref="barZoom1" :style="initStyle"></div>



  let option1 = {
        tooltip: {
          //鼠标移入效果
          trigger: "item",
          formatter: " {b} : {c} 个 <br/>  占比:({d}%)",
        },
        legend: {
          top: "center",
          right: 10,
          orient: "vertical",
          formatter: (name, value) => {
            let total = 0;
            let target;
            for (let i = 0; i < _that.info.data1.length; i++) {
              total += _that.info.data1[i].value;
              if (_that.info.data1[i].name === name) {
                target = _that.info.data1[i].value;
              }
            }
            let a = target / total ? ((target / total) * 100).toFixed(2) : 0;

            return (
              name + "{a||}" + "{b|" + a + "}" + "{b|%}" + "   " + target + "个"
            );
          },
          textStyle: {
            // 添加
            rich: {
              a: {
                padding: 4,
                color: "#999999",
              },
              b: {
                color: "#999999",
              },
            },
          },
        },
        color: [
          "#5B8FF9",
          "#61DDAA",
          "#78D3F8",
          "#93AFE4",

          "#BBDEDF",
          "#93CA3F",
          "#7F71FF",
          "#BAE379",
          "#FDCFCF",
          "#FEA76B",
          "#C18AD8",
          "#FAA0C5",
        ],

        series: [
          {
            type: "pie",
            radius: ["40%", "60%"],
            label: {
              //设置数据内容
              position: "center", //center的时候圆环中间显示数据
              show: false, //为false显示中间,为true显示指示线

              color: "#1E7CE8",
              lineHeight: 16,
              fontSize: 12,
              formatter: "{name|{b}} \n{value|{d}%} ",
              // formatter: "{d}% ",

              rich: {
                //设置样式
                value: {
                  fontSize: 14,
                  fontWeight: 600,
                  margin: "20px",
                  color: "#1D2129",
                },
                name: {
                  fontSize: 12,
                  color: "#595959",
                },
              },
            },
            itemStyle: {
              //每个圆环之间的间隙
              borderColor: "#fff",
              borderWidth: 1,
            },
            emphasis: {
              //鼠标移入时效果
              label: {
                show: true,
              },
            },
            center: ["25%", "50%"],
            data: _that.info.data1,
          },
        ],
      };
     
      _that.pieObj1 = this.$echarts.init(this.$refs.barZoom1);

    
      _that.pieObj1.setOption(option1);

      setTimeout(function () {
        window.onresize = function () {
       
          _that.pieObj1.resize();
        };
      }, 200);
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值