echarts-环形图-水球图

echarts

饼状/环形图

如图样式
首先实现环状图中间显示的数字,总量及文字,不同颜色显示

option:{
title: {
            zlevel: 0,//默认展示
            text: [
                '{value|' + "8.8kg" + '}',
                '{name|农药总量}',
            ].join('\n'),
         
            top: '35%',
            left: '29%',
            textAlign: 'center',
            textStyle: {
                rich: {
                    value: {
                        color: '#fff',
                        fontSize: 16,
                        fontWeight: 'bold',
                    },
                    name: {
                        color: '#00B8FF',
                        lineHeight: 30,
                        fontSize:14,
                        fontWeight:600
                        
                    },
                },
            },
        },
}

现在实现legend效果图

option:{
	legend:{
       orient: 'vertical',//纵向显示 "horizontal"==》横向显示
       right: '10px',
       top: 'center',
       icon: 'circle',
       itemWidth:6,
       textStyle: {
         rich: {//在rich里面,可以自定义富文本样式。利用富文本样式,可以在标签中做出非常丰富的效果。
             a: {
                 color: '#fff',
                 width: 30
             },
             c:{
            fontSize:13,
                align:'center',
                color:"#fff",
                padding: [0, 5, 0, 20]
        },
             b0: {
                 color: 'rgba(14,184,246)',
                 fontSize: 13,
             },
             b1: {
                 color: 'rgba(240,255,1)',
                 fontSize: 13,
             },
             b2: {
                 color: 'rgba(252,91,62)',
                 fontSize: 13,
             },
             b3: {
                 color: 'rgba(30,245,154)',
                 fontSize: 13,
             }
         }
     },
     formatter: function(name) {
         let title = ''
         var total = 0;
         var target;
         var index;
         var total;
         for (var i = 0, l = data.length; i < l; i++) {
             total += data[i].value;
             if (data[i].name == name) {
                 target = data[i].value;
                 title = data[i].label
                 index = i < 6 ? i : 5
             }
         }
         return `{a| ${name}}{c|${target}kg}{b${index}| ${((target/total)*100).toFixed(2)}%}个`	    
	},
}

在这里插入图片描述

水球图

在这里插入图片描述

myChart.clear() //清空绘画内容
loadjs(
    'https://echarts.baidu.com/resource/echarts-liquidfill-latest/dist/echarts-liquidfill.min.js'
    ,'asd',()=>{ //异步动态加载js
   var value = 0.20;
option = {
    backgroundColor:'rgba(0,0,0,0)', //背景
     title: {
         text: (value * 100).toFixed(0) + '{a|%}',//图形中间显示的文本
         textStyle: {
             fontSize: 14,
              color:"#fff",
             fontFamily: 'Microsoft Yahei',
             fontWeight: 'normal',
             rich: {
                 a: {
                     fontSize: 14,
                     color:"#fff"
                 }
             }
         },
         x: 'center',
         y: '35%'
     },
       center: ['30%', '50%'],
    series: [{
        type: 'liquidFill',
        name: 'Multi-Data',
      radius: '80%',
      data: [{'name':'实施中','value':"0.46"}],  //data
        outline: {
            show: false,
            },  
             color: {
             type: 'linear',
             x: 0,
             y: 0,
             x2: 0,
             y2: 1,
             colorStops: [{
                 offset: 1,
                 color: 'rgba(186,223,108)'//水波纹的颜色
             }],
             globalCoord: false
         },
        backgroundStyle: {
            color:"rgba(0, 0, 0, 0.4)",//水球图背景
            borderColor: 'rgba(235,181,29,0.05)',
            borderWidth: 15,
            shadowColor: 'rgba(235,181,29, 0.6)',
            shadowBlur: 30
        },
    
        label:{
            normal: {
                 formatter: '',//隐藏水球图原有样式
             }
        }
    }]
};
})
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值