echarts水波球特效(附带外边框进度条)

echarts水波球特效(附带外边框进度条)

1.话不多说先上效果图

在这里插入图片描述

2.这里用到了echarts的liquidFill图表,需要加载liquidFill插件

npm i echarts-liquidFill --save

3.在main.js入口文件中引入
在这里插入图片描述

4.也可通过script标签形式引入

<script src="http://echarts.baidu.com/resource/echarts-liquidfill-1.0.4/dist/echarts-liquidfill.js" type="text/javascript" charset="utf-8"></script>

5.option配置如下(可根据需要自行配置,大概的配置点已经注释出来了)

    chart.setOption({
        // backgroundColor: "#050038",
        title: {
          text: `总完成`,
          left: "center",
          top: "100",
          textStyle: {
            fontWeight: "normal",
            fontSize: 20,
            color: "rgb(0,0,0)"
          },
          subtext: `${this.progress.num}%`, //副标题
          subtextStyle: {
            fontWeight: "bold",
            fontSize: 40,
            color: "rgb(0,0,0)"
          }
        },

        series: [
          {
            type: "liquidFill", // 图表类型
            radius: "80%",
            center: ["50%", "50%"],
            data: [
              this.progress.num / 100,
              this.progress.num / 100,
              this.progress.num / 100
            ], // data个数代表波浪数
            backgroundStyle: {
              borderWidth: 1,
              color: "#F4F9FF"
            },
            label: {
              normal: {
                show: false, //不显示label  用副标题代替了
                formatter: (0.5 * 100).toFixed(0) + "%",
                textStyle: {
                  fontSize: 38,
                  color: "black"
                }
              }
            },
            color: [  //color一定要是个数组 ,每一项对应一个波浪,可以给每个波浪单独配置颜色
              {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 1,
                    color: "rgba(255,255,255,1)"
                  },
                  {
                    offset: 0,
                    color: "rgba(103,205,251,1)"
                  }
                ],
                globalCoord: false
              },
              {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 1,
                    color: "rgba(187,248,252,0.5)"
                  },
                  {
                    offset: 0,
                    color: "rgba(30,134,245,1)"
                  }
                ],
                globalCoord: false
              },
              {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 1,
                    color: "rgba(180,251,255,0.66)"
                  },
                  {
                    offset: 0,
                    color: "rgba(128,122,254,0.66)"
                  }
                ],
                globalCoord: false
              }
            ],
            outline: {
              show: false
            }
          },
          //外层线
          {
            type: "pie",
            center: ["50%", "50%"],
            radius: ["92%", "93%"], //外层线粗细
            hoverAnimation: false,
            data: [
              {
                name: "",
                value: 100,
                labelLine: {
                  show: false
                },
                itemStyle: {
                  color: "#67CDFB"
                },
                emphasis: {
                  labelLine: {
                    show: false
                  },
                  itemStyle: {
                    // color: "#5886f0"
                  }
                }
              }
            ]
          },
          //进度线
          {
            type: "pie",
            center: ["50%", "50%"],
            radius: ["90%", "95%"], //进度线粗细
            hoverAnimation: false,
            data: [
              {
                name: "",
                value: this.progress.num, //进度
                labelLine: {
                  show: false
                },
                itemStyle: {
                  color: {
                    type: "linear",
                    x: 0,
                    y: 0,
                    x2: 1,
                    y2: 2,
                    colorStops: [
                      // !! 在此添加渐变过程色 !!
                      { offset: 0, color: "#33E2ED" },
                      { offset: 1, color: "#807AFE" }
                    ]
                  }
                },
                emphasis: {
                  labelLine: {
                    show: false
                  },
                  itemStyle: {
                    // color: "#5886f0"
                  }
                }
              },
              {
                //画剩余的刻度圆环
                name: "",
                value: 100 - this.progress.num,
                itemStyle: {
                  color: "rgba(0,0,0,0)"
                },
                label: {
                  show: false
                },
                labelLine: {
                  show: false
                },
                emphasis: {
                  labelLine: {
                    show: false
                  },
                  itemStyle: {
                    color: "#050038"
                  }
                }
              }
            ]
          }
        ]
      });
(以上不足之处欢迎指出,共同进步)
  • 6
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
Echarts水波特效是通过使用echarts-liquidfill插件来实现的。你可以在官方网站https://www.npmjs.com/package/echarts-liquidfill找到该插件的详细信息。\[1\] 要使用水波特效,你需要引入Echarts.min.js和Echarts-liquidfill.js文件,并在HTML中创建一个具有定义了宽度和高度的DOM容器。然后,你可以使用以下代码初始化echarts实例并指定图表的配置项和数据:\[2\] ```html <script src="echarts.min.js"></script> <script src="echarts-liquidfill.js"></script> <script type="text/javascript"> var myChart = echarts.init(document.getElementById('main')); var option = { series: \[{ type: 'liquidFill', data: \[0.6\] }\] }; myChart.setOption(option); </script> ``` 如果你想要自定义水波特效的样式,你可以修改配置项中的相关属性。例如,你可以通过修改backgroundColor属性来设置背景颜色,通过修改title属性来设置标题的样式和位置,通过修改series属性中的data属性来控制数据展示,通过修改series属性中的color属性来控制水波的颜色渐变等。\[3\] 希望这些信息对你有帮助! #### 引用[.reference_title] - *1* [Echarts水波纹](https://blog.csdn.net/c_x_m/article/details/127558679)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Echarts图-多波纹和直线静止波纹](https://blog.csdn.net/weixin_43790703/article/details/122763100)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Echarts 水波图实现](https://blog.csdn.net/Liberal_w/article/details/129407075)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值