echarts环形图

 

<div class="piecharts" id="piecharts"></div>

 mounted() {
    this.piecharts = this.$echarts.init(document.getElementById("piecharts"));
    //图表缩放自适应
    window.addEventListener("resize", () => { 
      this.piecharts.resize();
    });
},

methods: {
    initpiecharts() {
      this.piecharts.clear();
      this.piecharts.setOption({
        animationDuration: 3000,
        title: {
          text: this.Title,
          textStyle: {
            color: "#DBE2FF",
            fontSize: this.fontSize(0.16),
          },
          top: this.fontSize(0.1),
          left: this.fontSize(0.1),
        },
        angleAxis: {
          max:
            this.piedata[0].Num +
            this.piedata[1].Num +
            this.piedata[2].Num +
            this.piedata[3].Num,
          axisLine: {
            show: false,
          },
          axisTick: {
            show: false,
          },
          splitLine: {
            show: false,
          },
          axisLabel: {
            show: false,
          },
        },
        radiusAxis: {
          type: "category",
          z: 10,
          axisLine: {
            show: false,
          },
          axisTick: {
            show: true,
          },
          splitLine: {
            show: false,
          },
          axisLabel: {
            show: false,
          },
        },
        polar: {
          radius: [50, "95%"],
          center: ["50%", "57%"],
        },
        series: [
          {
            type: "bar",
            barGap: this.fontSize(0.015),
            itemStyle: {
              color: "#F67246",
            },
            barCategoryGap: "-100%",
            barWidth: this.fontSize(0.06),
            showBackground: true,
            backgroundStyle: {
              color: "#151857",
            },
            data: [this.piedata[0].Num],
            coordinateSystem: "polar",
            name: "",
            emphasis: {
              focus: "series",
            },
          },
          {
            type: "bar",
            barGap: this.fontSize(0.015),
            itemStyle: {
              color: "#FAC837",
            },
            barCategoryGap: "-100%",
            barWidth: this.fontSize(0.06),
            showBackground: true,
            backgroundStyle: {
              color: "#151857",
            },
            data: [this.piedata[1].Num],
            coordinateSystem: "polar",
            name: "",
            emphasis: {
              focus: "series",
            },
          },
          {
            type: "bar",
            barGap: this.fontSize(0.015),
            itemStyle: {
              color: "#03DFEA",
            },
            barCategoryGap: "-100%",
            barWidth: this.fontSize(0.06),
            showBackground: true,
            backgroundStyle: {
              color: "#151857",
            },
            data: [this.piedata[2].Num],
            coordinateSystem: "polar",
            name: "",
            emphasis: {
              focus: "series",
            },
          },
          {
            type: "bar",
            barGap: this.fontSize(0.015),
            itemStyle: {
              color: "#028EEE",
            },
            barCategoryGap: "-100%",
            barWidth: this.fontSize(0.06),
            showBackground: true,
            backgroundStyle: {
              color: "#151857",
            },
            data: [this.piedata[3].Num],
            coordinateSystem: "polar",
            name: "",
            emphasis: {
              focus: "series",
            },
          },
        ],
      });
    },
//echats图中字体自适应
    fontSize(res) {
      let docEl = document.documentElement,
        clientWidth =
          window.innerWidth ||
          document.documentElement.clientWidth ||
          document.body.clientWidth;
      if (!clientWidth) return;
      let fontSize = 100 * (clientWidth / 1920);
      return res * fontSize;
    },
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值