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

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

npm i echarts-liquidFill --save

1. 在main.js入口文件中引入

也可通过script标签形式引入 

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

 2.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"
                  }
                }
              }
            ]
          }
        ]
      });
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值