vue中echarts实现水球动画图

实现如上图样式

思路:把后面图片用背景图片写入 中间水球图使用echarts中的liquidFill

由于自己是在vue中使用的 首先要用npm安装

npm i echarts-liquidfill -s

在页面引用

import "echarts-liquidfill";
//html模块

<div class="carLeft">
   <div class="carCharts" ref="carCharts"></div>
</div>


//css模块

 .carLeft{
        width: 1.4rem;
        height: 1.66rem;
        margin-right: 0.24rem;
        margin-top: 0.24rem;
        background: url(../assets/image/carBg.png) no-repeat;
        background-size: 100%;
        position: relative;
        .carCharts{
            position: absolute;
            top: 0.26rem;
            left: .13rem;
            width: .9rem;
            height: .9rem;
            // left: 0.1rem;
        }
    }

//js模块

                        var myChart = echarts.init(this.$refs.carCharts);
                        const echartsData =  [40, 60];

                        var option = {
                            waveLength:'100%',
                            // x轴
                            xAxis:{
                                show:false, // 不显示
                            },
                            // y轴
                            yAxis: {
                                show:false, // 不显示
                            },
                            grid:{
                                top:'2.5%',
                                right:'40',
                                bottom:'2.5%',
                                left:0,
                            },
                            series: [{
                                type: 'liquidFill',
                                radius: '100%',  // 半径大小
                                center: ['50%', '50%'],    // 布局位置
                                waveLength:'150',
                                data:echartsData, // 水球波纹值


                                //根据设计设置水波球背景颜色为透明
                                backgroundStyle: {
                                    color: 'rgba(255,255,255,0)',
                                },
                                outline: { // 轮廓设置  不展示
                                    show: false
                                },
                                itemStyle: {  
                                    //设置水球波动的渐变颜色
                                    color: {
                                        type: 'linear',
                                        x: 0,
                                        y: 0,
                                        x2: 0,
                                        y2: 1,
                                        colorStops: [{
                                            offset: 1,
                                            color: 'rgba(23,242,206, .65)'
                                        },  {
                                            offset: 0.9,
                                            color: 'rgba(23,242,206, .15)'
                                        },{
                                            offset: 0.4,
                                            color: 'rgba(23,242,206, .15)'
                                        },{
                                            offset: 0,
                                            color: 'rgba(12,255,215,1)'
                                        }],
                                        globalCoord: false
                                    }
                                },
                                //水球中间展示字体及颜色
                                label:{
                                    normal:{
                                        textStyle: {
                                            fontSize: 24,
                                            color:'#fff',
                                            fontWeight:400,
                                            formatter: '',
                                        }
                                    }
                                }
                            }]
                        };
                        myChart.clear();
                        myChart.resize();
                        myChart.setOption(option);

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值