echarts 饼图 多环


网上找了好多博客,都不是很详细。摸爬滚打一上午,总结一下
相当于series里三个饼图,radius:[100,220]第一个表示内径和外径 相差值就是环的大小,数据自己提前准备好放到legend 的 data 以及对应环的name

option = {
        tooltip: {
            show:false,//防止鼠标移到不需要的数据上弹出label
            trigger: 'item',
            formatter: "{a} : {c} ({d}%)"
        },
        color:['#dc1439','#e6b600','#053afe'],
         legend: {
            orient: 'vertical',
            x: '30%',
            top:'19%',
            itemHeight: 10,//图例的高度
            itemGap:5,//图例之间的间距 
            data:['未开工'+preBuild+'%','竣工'+finishPercent+'%','在建'+inBuild+'%']//图例的名字需要和饼图的name一致,才会显示图例
        },
        series: [
            {
                name:'在建'+inBuild+'%',
                type:'pie',
                radius: ['35%', '30%'],//环的位置

                label: {
                    normal: {
                        position: 'inner'
                    }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                data:[
                    {value:inBuildNum, //需要显示的数据
                    itemStyle: {
                                normal: {
                                 color: '#dc1439'
                                }
                     }},
                   {value:total-inBuildNum, //不需要显示的数据,颜色设置成和背景一样
                    itemStyle: {
                                normal: {
                                 color: 'transparent'
                                }
                     }}
                ]
            },
            {
                name:'竣工'+finishPercent+'%',
                type:'pie',
                radius: ['40%', '45%'],

                label: {
                    normal: {
                        position: 'inner'
                    }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                data:[
                    {value:finishNum, 
                    itemStyle: {
                                normal: {
                                 color: '#e6b600'
                                }
                     }},
                   {value:total-finishNum, 
                    itemStyle: {
                                normal: {
                                 color: 'transparent'
                                }
                     },
                   }
                ]
            },
            {
                name:'未开工'+preBuild+'%',
                type:'pie',
                radius: ['55%', '50%'],

                label: {
                    normal: {
                        position: 'inner'
                    }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                data:[
                    {value:preBuildNum, 
                    itemStyle: {
                                normal: {
                                 color: '#053afe'
                                }
                     }},
                   {value:total-preBuildNum, 
                    itemStyle: {
                                normal: {
                                 color: 'transparent'
                                }
                     }}
                ]
            },
        ]
    };
  • 4
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值