echarts多层环形图

//来自一个大佬的恩赐
https://www.cnblogs.com/wasbg/p/13050415.html


var pass_rate = 70,average = 60,total = 100;
option = {
        tooltip: {
            show:false,
            trigger: 'item',
            formatter: "{a} : {c} ({d}%)"
        },
        //  color: ['#85b6b2', '#6d4f8d'],
         color: ['rgb(255,159,127)', 'rgb(50,197,233)'],
         legend: {
            orient: 'vertical',
            x: '35%',
            top:'27%',
            itemHeight: 10,//图例的高度
            itemGap:8,//图例之间的间距
            data:['通过率'+pass_rate+'%','平均值'+average+'%']
            //图例的名字需要和饼图的name一致,才会显示图例
        },
        series: [
            {
                name:'通过率'+pass_rate+'%',
                type:'pie',
                radius: ['40%', '45%'],
                //环的位置
                label: {
                   show: false,
                   position: 'center',
                    // normal: { // 显示的位置
                    //     position: 'inner'
                    // }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                emphasis: {
                    label: {
                        show: true,
                        fontSize: '20',
                        fontWeight: 'bold'
                    }
                },
                data:[
                    {
                      value:pass_rate, //需要显示的数据
                      name: '通过率'+pass_rate+'%',
                      itemStyle: {
                        normal: {
                         color: 'rgb(255,159,127)'
                        }
                      }
                    },
                    {
                      value:total-pass_rate,
                      //不需要显示的数据,颜色设置成和背景一样
                      itemStyle: {
                        normal: {
                         color: 'transparent'
                        }
                      }
                   }
                ]
            },
            {
                name:'平均值'+average+'%',
                type:'pie',
                radius: ['30%', '35%'],
                label: {
                   show: false,
                   position: 'center',
                    // normal: {
                    //     position: 'inner'
                    // }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                emphasis: {
                    label: {
                        show: true,
                        fontSize: '20',
                        fontWeight: 'bold'
                    }
                },
                data:[
                    {   name:'平均值'+average+'%',
                        value:average,
                        itemStyle: {
                            normal: {
                             color: 'rgb(50,197,233)'
                            }
                        }
                    },
                   {
                        value:total-average,
                        itemStyle: {
                            normal: {
                                color: 'transparent'
                            }
                         }
                   }
                ]
            }
        ]
    };

样图:在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值