Echart使用水球图不生效

文章讲述了在Vue3中尝试使用Echarts5绘制水球图时遇到的问题,由于Echarts5.0版本后需要单独安装echarts-liquidfill依赖,提供了相应的安装步骤和版本对应建议。
摘要由CSDN通过智能技术生成

一、背景:

        在vue3中使用echart5绘制水球图,未显示,也没有报错。

        水球图官方链接:https://www.npmjs.com/package/echarts-liquidfill

二、原因:

        echart5.0版本后需要单独安装依赖包。

三、解决方案:

1、安装水球图的依赖包

npm i echarts-liquidfill

2、在使用的vue页面

import * as echarts from 'echarts';
import 'echarts-liquidfill';

注:

         1、Echarts的版本需要和‘echarts-liquidfill’。

echartsecharts-liquidfill
^5.3.3^3.1.0
^4.2.1^2.0.2

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 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、付费专栏及课程。

余额充值