echarts 饼图 中间 画圈 + 文字

项目场景:

在饼图中间加入圈和文字,且会随着饼图位置改变,三者位置处于相对静止

效果如下:在这里插入图片描述

代码描述

option = {
    backgroundColor: '#000',
      tooltip: {
        trigger: 'item',
        formatter: '{b} <br/>{c}: ({d}%)',
      },
      color: ['#61a0a8', '#d48265', '#23e5fd'],
      legend: {
        orient: 'vertical',
        top: 'center',
        left: '60%',
        // formatter:'{b}<br/>{c})',
        itemGap: 30,
        textStyle: {
          color: 'white',
          fontSize: '20px',
          // lineHeight: '50px'
        },
        icon: 'circle',
        itemWidth: 8,
      },

      series: [
        {
          name: 'Access From',
          type: 'pie',
          radius: ['60%', '70%'],
          center: ['30%', '50%'],
          avoidLabelOverlap: false,
         
          label: {
            normal: {
                show: true,
                position: 'center',
                color:'#fff',
                // text: '1111'
            formatter: '{total|2000}\n{active|总面积}', 
            rich: { 
                total:{ 
                    fontSize: 35, 
                    // fontFamily : "微软雅黑", 
                    color:'#23e5fd'                     
                },
                active: { 
                // fontFamily : "微软雅黑", 
                    fontSize: 16, color:'#fff', 
                    lineHeight:30,             
                },          
            }             
        },       
      },        
          labelLine: {
            show: false,
          },
          data: [
            { value: 300, name: '公共区面积' },
            { value: 120, name: '未占用面积' },
            { value: 3180, name: '已占用面积' },
          ],
        },
        {
            color: ['#61a0a8'],
           
            type: 'pie',
            // clockWise: false, //顺时加载
            hoverAnimation: false, //鼠标移入变大
            center: ['30%', '50%'],
            radius: ['48%', '50%'],
            label: {
                normal: {
                     show: false
                }
            },
            data: [{
                value: 9,
                name: '',
                itemStyle: {                    
                }
            }]
        },
      ],
    }

解决方案:

圈用一个新的饼图实现
文字:在label中,且可以自定义多种文字属性

补充::
用的时候label中无法使用nomal
label: {
show: true,
position: ‘center’,
color:’#fff’,
// text: ‘1111’
formatter: ‘{total|2000}\n{active|总面积}’,
rich: {
total:{
fontSize: 35,
// fontFamily : “微软雅黑”,
color:’#23e5fd’
},
active: {
// fontFamily : “微软雅黑”,
fontSize: 16, color:’#fff’,
lineHeight:30,
},
},

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值