echart水球样式

 

       

<html>
    <head>
        <meta charset="utf-8">
     <script src='./js/echarts.min.js'></script>
        <script src='./js/echarts-liquidfill.min.js'></script>
    </head>
    <body>
        <style>
            
        </style>
        <div id='main' style="width: 200px;height: 200px;">
            
           
           
           
        </div>
        <script>
           initChart();
         function initChart(){
                let myLiuqiud = document.getElementById("main");
                var myChart = echarts.init(myLiuqiud);
                var value =78;
                let option = {
                  
                  title: {
                    text: value + "%",
                    textStyle: {
                      fontSize: 24,
                      fontFamily: "Microsoft Yahei",
                      fontWeight: "600",
                      color: "#fff",
                      textShadowColor:'#000',
                           textShadowBlur: 2,
                           textShadowOffsetX: 2,
                           textShadowOffsetY: 2.5,
                    },
                    x: "center",
                    y: "50%",
                  },
                  textStyle: {
                      shadowColor: 'rgba(0, 0, 0, 0)',
                  },
                  series: [
                      
                    {
                        textStyle: {
                                   textShadowColor:"rgba(183, 63, 63, 1)",
                                    textShadowBlur: 2,
                                    textShadowOffsetX: 2,
                                    textShadowOffsetY: 2.5,
                                  fontSize: 14,
                                  lineHeight:35,
                                  color:"#939393",
                                  
                                                        
                        },
                        // 图形样式
                      itemStyle: {
                        opacity: 1, // 波浪的透明度
                        shadowBlur: 0 ,// 波浪的阴影范围 设置为0不会出现底色为灰色的情况
                        shadowColor: 'rgba(0, 0, 0, 0)',
                        
                      },
                      type: "liquidFill", //配置echarts图类型
                      radius: "60%",
                      center: ["50%", "50%"],
                      //  shape: 'roundRect',// 设置水球图类型(矩形[rect],菱形[diamond],三角形[triangle],水滴状[pin],箭头[arrow]...) 默认为圆形
                      data: [0.78],  //设置波浪的值 
                      waveAnimation:false, //静止的波浪
                      backgroundStyle: {
                        borderWidth: 11,
                        color: "#f4f4f4",//水球图内部背景色
                      },
                      outline: { 
                        borderDistance: 0, 
                        itemStyle: {
                          borderWidth:4,
                          borderColor: "#f1f1f1",
                        },
                      },
                      // color: [ //波浪颜色
                      //   {
                      //     type: "linear",
                      //     x: 0,
                      //     y: 0,
                      //    x2: 0,
                      //    y2: 1,
                      //     colorStops: [
                      //       {
                      //         offset: 0,
                      //         color: "#178bff", //下
                      //       }
                      //     ],
                      //     globalCoord: false,
                      //   },{
                      //     type: "linear",
                      //     x: 0,
                      //     y: 0,
                      //    x2: 0,
                      //    y2: 1,
                      //     colorStops: [
                      //       {
                      //         offset: 0,
                      //         color: "#188bff", //下
                      //       }
                      //     ],
                      //     globalCoord: false,
                      //   }
                      // ],
                       color: [ //波浪颜色
                                    {
                                      type: "linear",
                                      x: 0,
                                      y: 0,
                                      x2: 1,
                                      y2: 0,
                                      colorStops: [
                                        {
                                          offset: 1,
                                          color: "#1188ff", //下
                                        },
                                        {
                                          offset: 0,
                                          color: "#81c1ff",
                                        },
                                      ],
                                      globalCoord: false,
                                    },
                                   
                                  ],
                    
                      label: {
                          normal: {
                              textShadow:' 3px 3px 3px #000',
                              // insideColor: 'transparent', // 避免文字显示为白色
                              formatter: '出勤率\n',
                              textStyle: {
                                  
                                  fontSize: 14,
                                  lineHeight:35,
                                  color:"#939393",
                                
                              }
                          }
                      }
                    },
                    
                  ],
                };
                option && myChart.setOption(option);
              }
        

           
        </script>
    </body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用ECharts绘制水球图的示例代码: ```html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>ECharts 水球图示例</title> <!-- 引入 ECharts 文件 --> <script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script> </head> <body> <!-- 为 ECharts 准备一个具备大小(宽高)的 DOM --> <div id="main" style="width: 600px;height:400px;"></div> <script type="text/javascript"> // 基于准备好的dom,初始化echarts实例 var myChart = echarts.init(document.getElementById('main')); // 指定图表的配置项和数据 var option = { series: [{ type: 'liquidFill', data: [0.6, 0.5, 0.4, 0.3], radius: '70%', label: { normal: { formatter: '{a|{a}}{abg|}\n{hr|}\n {b|{b}:}{c}%', backgroundColor: '#eee', borderColor: '#aaa', borderWidth: 1, borderRadius: 4, shadowBlur:3, shadowOffsetX: 2, shadowOffsetY: 2, shadowColor: '#999', padding: [0, 7], rich: { a: { color: '#999', lineHeight: 22, align: 'center' }, hr: { borderColor: '#aaa', width: '100%', borderWidth: 0.5, height: 0 }, b: { color: '#333', fontSize: 16, fontWeight: 'bold', lineHeight: 33 }, per: { color: '#eee', backgroundColor: '#334455', padding: [2, 4], borderRadius: 2 } } } }, backgroundStyle: { color: 'rgba(220, 220, 220, 0.8)' }, itemStyle: { normal: { opacity: 0.6, shadowBlur: 10, shadowColor: 'rgba(0, 0, 0, 0.3)' } } }] }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); </script> </body> </html> ``` 以上代码会生成一个宽为600px,高为400px的水球图,其中data数组中的四个元素分别表示四个水球的填充百分比。你可以根据自己的需求修改这些参数。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值