Echart环形图

在这里插入图片描述

var colorList = ["#034079", "#49DFF0", "#DFB141", "#00FEB5", "#7081DB", "#FDFEFF", "#2385E0"];
option = {
    title: {
        text: '学生各学年消费细则分析',
        textStyle: {
            color: '#fff',
        },
    },
    backgroundColor: '#ccc', //背景颜色
     tooltip: {  //放鼠标到圆环上会显示的提示文字
       trigger: 'item',
       formatter: "{b}: {c} ({d}%)"
    },
    // grid: {
    //     top: '1%',
    //     containLabel: true
    // },
    series: [{
    	// center:[200,100], //饼图的位移
        type: 'pie',
        radius: ['27%', '53%'],
        // roseType: 'radius',
        clockwise: false, // 是否顺时针
        z: 5,
        itemStyle: { // 每块数据的颜色
            normal: {
             	borderColor: '#04192b', // 每块数据 边框的颜色
                borderWidth: 1  // 边框粗细
                color: function(params) {
                    // build a color map as your need.
                    return colorList[params.dataIndex]
                },
                // shadowBlur: 20,  //阴影
                // shadowColor: 'rgba(0, 0, 0, 0.3)' // 透明度
            }
        },
        // 如图:学费 文字
        label: {
            normal: {
                show: false,
                color:'#000',
                fontSize:15,
                formatter: (params,ticket,callback)=>{
                    return params.name+'\n'+params.percent+'%'
                },
                // rich: {
                //     b: {
                //         fontSize: 12,
                //         color: '#fff',
                //         align: 'left',
                //         padding: 4
                //     },
                //     hr: {
                //         //		                            			borderColor: '#12EABE',
                //         width: '100%',
                //         borderWidth: 1,
                //         height: 0
                //     },
                //     d: {
                //         fontSize: 12,
                //         color: '#fff',
                //         align: 'left',
                //         padding: 1
                //     },
                //     c: {
                //         fontSize: 12,
                //         color: '#fff',
                //         align: 'center',
                //         //		                            padding: 4
                //     }
                // }
            }
        },
		// 文字连接 圆环的线
        labelLine: {
            normal: {
                length: 20, //第一节线的长度
                length2: 30, //第二节线的长度
                lineStyle: { 
                    width: 1, // 线的粗细
                     color:'#000'
                },
               
            }
        },
        // 鼠标放到圆环的时候才会显示 学费 和 连接圆环的线
        emphasis: {
                label: {
                    show: true
                }    
            },
        data: [{
                value: 50,
                name: '吃饭'
            },
            {
                value: 50,
                name: '学费'
            },
            {
                value: 50,
                name: '买护理品'
            },
            {
                value: 40,
                name: '买衣服'
            },
            {
                value: 30,
                name: '买文具'
            },
            {
                value: 10,
                name: '其他'
            },
            {
                value: 20,
                name: '买零食'
            },
        ]
    }]
};
// data 无数据的时候展示的---暂无数据
 title: {

   show: Object.keys(data).length === 0,

   extStyle: {

     color: "grey",

     fontSize: 20

 },

  text: "暂无数据",

  left: "center",

  top: "center"

   },
// 另一种数据模式
data:[
      		  {
                    value:100, name:'其它',
                    itemStyle: {
                        color: {
                            type: 'radial',
                            x: 550,
                            y: 440,
                            r: 120,
                            colorStops: [{
                                offset: 0, color: 'rgba(235,232,6, 0.2)' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#EBE806' // 100% 处的颜色
                            }],
                            // global: true // 缺省为 false
                        }
                    },
                    labelLine: {
                        lineStyle: {
                            color: '#EBE806'
                        }
                    }
                },
                {
                    value:30, name:'平安保险',
                    itemStyle: {
                        color: {
                            type: 'radial',
                            x: 550,
                            y: 440,
                            r: 120,
                            colorStops: [{
                                offset: 0, color: 'rgba(255,86,36, 0.2)' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#FF5624' // 100% 处的颜色
                            }],
                            global: true // 缺省为 false
                        }
                    },
                    labelLine: {
                        lineStyle: {
                            color: '#FF5624'
                        }
                    }
                },
                {
                    value:30, name:'太平洋保险',
                    itemStyle: {
                        color: {
                            type: 'radial',
                            x: 550,
                            y: 440,
                            r: 120,
                            colorStops: [{
                                offset: 0, color: 'rgba(94,166,254, 0.2)' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#5EA6FE' // 100% 处的颜色
                            }],
                            global: true // 缺省为 false
                        }
                    },
                    labelLine: {
                        lineStyle: {
                            color: '#5EA6FE'
                        }
                    }
                },
                {
                    value:30, name:'中国人保',
                    itemStyle: {
                        color: {
                            type: 'radial',
                            x: 550,
                            y: 440,
                            r: 120,
                            colorStops: [{
                                offset: 0, color: 'rgba(0,222,215, 0.2)' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#37FFF9' // 100% 处的颜色
                            }],
                            global: true // 缺省为 false
                        }
                    },
                    labelLine: {
                        lineStyle: {
                            color: '#ccc'
                        }
                    }
                },
                
            ]
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值