echarts实现半圆饼图

本文档将指导你如何利用ECharts库来实现一个吸引人的半圆饼图。通过实例代码和配置,详细解析了从初始化图表到设置饼图形状为半圆的过程,适合想要在项目中应用ECharts的开发者参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

var myChart = this.$echarts.init(document.getElementById('myChart'))
      let data = [
        {
          value: 57,
          name: '半年分配',
          itemStyle: {
            normal: {
              color: '#087EE0',
              label: {
                show: true,
                formatter: '{c}%',
                textStyle: {color: '#fff'}
              }
            }
          }
        },
        {
          value: 14,
          name: '按月分配',
          itemStyle: {
            normal: {
              color: '#79ADF9',
              label: {
                show: true,
                formatter: '{c}%',
                textStyle: {color: '#fff'}
              }
            }
          }
        },
        {
          value: 29,
          name: '到期分配',
          itemStyle: {
            normal: {
              color: '#C4D5FF',
              label: {
                show: true,
                formatter: '{c}%',
                textStyle: {color: '#fff'}
              }
            }
          }
        }]
      var a = 0
      for (let i = 0; i < data.length; i++) {
        a += data[i].value
      }
      data.push({value: a, name: '__other', itemStyle: {normal: {color: 'rgba(0,0,0,.0)'}}})
      let option = {
        series : [
          {
            name: '产品分配方式',
            type: 'pie',
            startAngle:-180,
            radius : '55%',
            center: ['50%', '60%'],
            data:data,
            itemStyle: {
              emphasis: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            },
            label: {
              normal: {
                show: true,
                position: 'inside',
                formatter: '{c}%'
              }
            }
          }
        ]
      }
      myChart.setOption(option)

参考文章:http://gallery.echartsjs.com/editor.html?c=xH1h_3TvEx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值