Echarts饼图2.0(三层圆环)

代码:

const item = {
    value: 0.75,
    status: '这是我的标签',
    name: '这是我的名称'
}

option = {
    angleAxis: {
      max: 100,
      clockwise: false,
      axisLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        show: false
      },
      splitLine: {
        show: false
      }
    },
    radiusAxis: {
      type: 'category',
      axisLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        show: false
      },
      splitLine: {
        show: false
      }
    },
    polar: {
      center: ['50%', '50%'],
      radius: '192%'
    },
    series: [
      { // 绘制最外侧灰色的圆弧
        z: 1,
        type: 'pie',
        radius: ['98%', '96%'],
        center: ['50%', '50%'],
        data: [{
          value: 0,
          itemStyle: {
            normal: {
              color: '#eee'
            }
          },
          label: {
            show: true,
            formatter: [`{a|${item.value !== '--' ? (Math.abs(item.value) * 100).toFixed(2) + '%' : '--'}}`, `{b|${item.name}}`, `{d|}`, `{c|${item.status}}`].join('\n'),
            position: 'center',
            rich: {
              a: {
                fontSize: 72,
                color: '#d0021b',
                textAlign: 'center',
                padding: [0, 0, 12, 0]
              },
              b: {
                fontSize: 36,
                color: '#999',
                padding: [0, 0, 12, 0]
              },
              c: {
                padding: [8, 6, 6, 6],
                backgroundColor: 'rgba(208,2,27,0.5)',
                fontSize: 20,
                color: '#fff'
              }
            }
          },
          labelLine: {
            normal: {
              smooth: true,
              lineStyle: {
                width: 0
              }
            }
          },
          hoverAnimation: false
        },
        {
          label: {
            show: false
          },
          labelLine: {
            normal: {
              smooth: true,
              lineStyle: {
                width: 0
              }
            }
          },
          value: 100 - Math.floor((Math.abs(item.value) * 100)),
          hoverAnimation: false,
          itemStyle: {
            color: '#eee',
            emphasis: { // 鼠标移入不高亮
              color: '#eee'
            }
          }
        }
        ]
      },
      { // 绘制最里侧灰色的圆弧
        type: 'pie',
        center: ['50%', '50%'],
        radius: ['84%', '82%'],
        data: [{
          label: {
            show: false
          },
          labelLine: {
            normal: {
              smooth: true,
              lineStyle: {
                width: 0
              }
            }
          },
          value: 0,
          hoverAnimation: false,
          itemStyle: {
            color: '#eee',
            emphasis: { // 鼠标移入不高亮
              color: '#eee'
            }
          }
        }]
      },
      { // 绘制最外侧带颜色的圆弧
        z: 3,
        type: 'bar',
        data: [{
          value: (Math.abs(item.value) * 100),
          itemStyle: {
            normal: {
              color: '#d0021b'
            }
          }
        }],
        coordinateSystem: 'polar',
        barWidth: 4
      }
    ]
  }

最终的效果:

在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值