echarts实现水滴图

使用echarts实现水滴图

引入依赖,echarts-liquidfill@3兼容echarts@5; 安装依赖
 "echarts": "^5.4.3",
 "echarts-liquidfill": "^3.1.0",
npm install echarts-liquidfill@3.1.0 -S
实现的效果图

在这里插入图片描述

构建一个水滴图的页面
<template>
  <div class="dlsFirst">
    <div style="padding: 50px;">达标情况</div>
    <div class="gender-con" id="proportionCon"></div>
  </div>
</template>
<script>
import "echarts-liquidfill/src/liquidFill.js"; //js引入
export default {
  data() {
    return {
     
    };
  },
  mounted() {
   const myChart = echarts.init(document.getElementById('proportionCon'));
   const option = {
          // backgroundColor: "#485C6D", //背景色
          series: [
              {
                  type: "liquidFill", //水位图
                  radius: "90%", //显示比例
                  center: ["50%", "50%"], //中心点
                  amplitude: 20, //水波振幅
                  data: [0.5], // data个数代表波浪数
                  backgroundStyle: {
                      borderWidth: 5, //外边框
                      borderColor: "#33c8ff", //边框颜色
                      // color: "#485C6D" //边框内部填充部分颜色
                  },
                  // color: ["#4db6ac"], //波浪颜色
                  //这是设置波浪渐变色
                  itemStyle: {
                      normal: {
                          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                              {
                                  offset: 0,
                                  color: '#e744ff',
                              },
                              {
                                  offset: 1,
                                  color: '#33c8ff',
                              },
                          ]),
                      },
                  },
                  label: {
                      //标签设置
                      position: ["50%", "30%"],
                      formatter: (params)=>{
                          return (params.data * 100) + '%'
                      }, //显示文本,
                      fontSize: "20px", //文本字号,
                      color: "#fff"
                  },
                  outline: {
                      show: false //最外层边框显示控制
                  }
              }
          ]
      }
      let dbz={
          max:1000,
          value:633
      }
      option.series[0].data = [dbz.value / dbz.max]
  
    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
  },
};
</script>

<style scoped>
  .gender-con{
    width:260px;
    height:300px;
  }
</style>

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值