vue2.x + echart 5.x 实现环形利用率图

<template>
  <div ref="main" class="rate-chart"></div>
</template>
<script>
import * as echarts from 'echarts'
export default {
  methods: {
    init() {
      const myChart = echarts.init(this.$refs.main)
      let value = 65.52
      const option = {
        series: [
          {
            clockwise: true,
            hoverAnimation: false,
            legendHoverLink: false,
            hoverOffset: 0,
            name: '外层空心圆',
            type: 'pie',
            radius: ['98%', '98%'],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: 'center'
            },
            labelLine: {
              show: false
            },
            itemStyle: {
              borderColor: '#414141',
              borderWidth: 2
            },
            data: [{ value: 0 }]
          },
          {
            clockwise: true,
            hoverAnimation: false,
            legendHoverLink: false,
            hoverOffset: 0,
            name: '内层空心圆',
            type: 'pie',
            radius: ['60%', '60%'], // 设置内外半径
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: 'center'
            },
            labelLine: {
              show: false
            },
            data: [{ value: 0, name: '' }],
            itemStyle: {
              borderColor: '#414141',
              borderWidth: 2,
              color: 'none'
            }
          },
          {
            type: 'pie',
            radius: ['86%', '70%'],
            silent: true,
            clockwise: true,
            startAngle: 0,
            z: 0,
            zlevel: 0,
            data: [
              {
                value: value,
                itemStyle: {
                  color: '#FF4500'
                },
                label: {
                  position: 'center',
                  fontSize: 14,
                  color: '#fff',
                  formatter: function () {
                    return value + '%'
                  }
                }
              },
              {
                value: 100 - value,
                label: {
                  show: false
                },
                itemStyle: {
                  normal: {
                    color: '#414141'
                  }
                }
              }
            ]
          },
          {
            name: '',
            type: 'gauge',
            radius: '88%',
            center: ['50%', '50%'],
            startAngle: 0,
            endAngle: 360,
            splitNumber: 10,
            hoverAnimation: true,
            axisTick: {
              show: false
            },
            splitLine: {
              length: '20%',
              distance: -10,
              lineStyle: {
                width: '4',
                color: '#000'
              }
            },
            axisLabel: {
              show: false
            },
            pointer: {
              show: false
            },
            axisLine: {
              show: false
            }
          }
        ]
      }
      myChart.setOption(option)
    }
  },
  mounted() {
    this.init()
  }
}
</script>

<style scoped lang="less">
.rate-chart {
  width: 100%;
  height: 100%;
}
</style>
实现方式:
3个饼图 +  1个仪表盘图(做分割用)

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

web_Hsir

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值