echart饼图已经有label显示,再添加饼图中心显示文本

echart中的:graphic;直接加进去就可以

 graphic: {
          type: 'text',
          left: 'center',
          top: 'center',
          zlevel: 100,
          style: {
            text: '{b|'+allTotal+'台}',
            rich: {
              b: {
                fontSize: 25, // 不同样式的字号
              }
            },
            fill: '#15E5E5', // 文本颜色
            textAlign: 'center',
            letterSpacing: 3 // 设置字间距
          }
        },

graphic里面还可以添加很多层

  graphic: [
                {
                    type: 'group', // 图形类型为group,可以包含多个子图形元素
                    left: 'center',
                    top: 'center',
                    children: [
                       /*  {
                            type: 'circle', // 子图形元素类型为circle,圆形
                            z: 80, // 设置z轴高度,确保在饼状图上层显示
                            left: 'center',
                            top: 'center',
                            shape: {
                                r: 47, // 半径,控制圆形大小
                            },
                            style: {
                                stroke: '#05688D', // 边框颜色
                                lineWidth: 2, // 边框线宽
                                lineDash: [5, 5], // 虚线 
                            }
                        },
                        {
                            type: 'circle',
                            z: 80, // 设置z轴高度,确保在饼状图上层显示
                            left: 'center',
                            top: 'center',
                            shape: {
                                cx: 0,
                                cy: 0,
                                r: 45, // 半径,控制圆形大小
                            },
                            style: {
                                fill: new echarts.graphic.RadialGradient(0.5, 0.5, 0.5, [
                                    {
                                        offset: 0,
                                        color: '#006BC9'
                                    },
                                    {
                                        offset: 1,
                                        color: '#002B50'
                                    }
                                ]),
                                stroke: 'transparent', // 边框颜色设置为透明
                                lineWidth: 0, // 边框线宽设置为0,确保没有边框
                            }
                        }, */
                        {
                            type: 'text', // 子图形元素类型为text,文本
                            z: 80, // 设置z轴高度
                            left: 'center',
                            top: 'center',
                            style: {
                                text:
                                    `{a|总数}\n{b|${numValue}}{a|${numUnit}}`, // 文本内容
                                rich: {
                                    a: {
                                        fontSize: 15,
                                        fontFamily: 'PingFang Bold',
                                        color: '#00FFFF',
                                        lineHeight: 25, // 设置行高
                                    },
                                    b: {
                                        fontSize: 25, // 不同样式的字号
                                        color: '#FF0000', // 不同样式的颜色
                                        fontFamily: "DS-DIGI-1",// 其他样式属性
                                    },
                                },
                                fill: '#00FFFF', // 文本颜色
                                textAlign: 'center',
                                letterSpacing: 3, // 设置字间距
                            }
                        }
                    ]
                }
            ]

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值