vue echarts 圆环饼图

28 篇文章 5 订阅

通过控制起始角度实现

<template>
  <div style="height:100%;width:100%;">
    <div id="myCharted" :style="{width: '100%', height: '100%'}"></div>
  </div>
</template>
<script>
import echarts from "echarts";
export default {
  data() {
    return {};
  },
  // props: {
  //     xvalue:Array,
  //     servalue:Array
  // },
  mounted() {
    this.drawLine();
  },
  methods: {
    drawLine() {
      // 基于准备好的dom,初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById("myCharted"));
      myChart.setOption({
        legend: {
          show: false
        },
        series: [
             {
            name: "",
            type: "pie",
            clockWise: false,
            radius: ["40%", "45%"],
            center: ["15%", "25%"],
            itemStyle: {
              normal: {
                label: {
                  show: false
                },
                labelLine: {
                  show: false
                },
                shadowBlur: 0,
                shadowColor: "#183665"
              }
            },
            hoverAnimation: false,
            startAngle: -60,
            data: [
              {
                value: 15,
                name: "",
                label: {
                  normal: {
                    rich: {
                      a: {
                        color: "#D0D0D0",
                        align: "center",
                        fontSize: 16,
                        fontWeight: "bold",
                        lineHeight: 30
                      },
                      b: {
                        color: "#fff",
                        align: "center",
                        fontSize: 18   // '90%' 百分比代替
                      },
                      c:{
                        fontSize: 16
                      }
                    },
                    formatter: function(params) {
                      return "{b|30} " + "{a|℃}" +"\n{c|空气温度}";
                    },
                    position: "center",
                    show: true
                  }
                },
                itemStyle: {
                  normal: {
                    color: "#17F4A5"
                  }
                }
              },
              {
                value: 10,
                name: "01",
                itemStyle: {
                  normal: {
                    color: "rgba(255,300,305,0.8)",
                    label: { show: false },
                    labelLine: { show: false }
                  }
                }
              }
            ]
          }
        ]
       });
      window.onresize = myChart.resize;
    }
  }
};
</script>
<style lang="less" scoped>
</style>





 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值