在uview/uni-app中使用echart插件动态刷新图表

在使用Echarts-for-Weixin-miniprogram时遇到动态刷新柱状图,图例更新但数据未同步。解决方案在于在uni-ec-canvas.vue文件的setOption方法中添加第二个参数true,确保数据强制刷新。参考Echarts官网了解更多。
摘要由CSDN通过智能技术生成

这个插件目前只支持在微信小程序中使用,具体安装使用请参考地址:echart-for-weixin-miniprogram

在使用过程中发现动态刷新图表时会出现图例发生了变化,但图表数据没有更新。我是在柱状图中遇到的。

解决方法:在uni-ec-canvas.vue文件中205行中setOption 第二个参数写true就行了

setOption(val) {
        if (!this.$curChart || !this.$curChart.setOption) {
          this.toHandleList.push(val);
        } else {
          this.$curChart.setOption(val,true);//这里加第二个参数 true
        }
      },

具体含义可参考echarts官网:echarts

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
11:10:22.921 WARNING: Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-cell-item/u-cell-item.vue' in 'D:\ideaWorkSpace\ehl-wx\applicationCenter\examine' 11:10:22.922 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-cell-item/u-cell-item.vue' in 'D:\ideaWorkSpace\ehl-wx\applicationCenter\pensionResources' 11:10:22.931 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-mask/u-mask.vue' in 'D:\ideaWorkSpace\ehl-wx\pages\service' 11:10:22.936 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-section/u-section.vue' in 'D:\ideaWorkSpace\ehl-wx\applicationCenter\examine' 11:10:22.942 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-section/u-section.vue' in 'D:\ideaWorkSpace\ehl-wx\applicationCenter\knowledgeBase' 11:10:22.946 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-section/u-section.vue' in 'D:\ideaWorkSpace\ehl-wx\pages\notice' 11:10:22.950 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-select/u-select.vue' in 'D:\ideaWorkSpace\ehl-wx\applicationCenter\examine' 11:10:22.957 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-select/u-select.vue' in 'D:\ideaWorkSpace\ehl-wx\applicationCenter\knowledgeBase' 11:10:22.962 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-select/u-select.vue' in 'D:\ideaWorkSpace\ehl-wx\pages\service' 11:10:22.968 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-select/u-select.vue' in 'D:\ideaWorkSpace\ehl-wx\subpages\assessment-admission' 11:10:22.975 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-select/u-select.vue' in 'D:\ideaWorkSpace\ehl-wx\subpages\assessment-orgHomeBed' 11:10:22.975 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-select/u-select.vue' in 'D:\ideaWorkSpace\ehl-wx\subpages\assessment-respiteCare' 11:10:22.983 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-th/u-th.vue' in 'D:\ideaWorkSpace\ehl-wx\applicationCenter\fms' 11:10:22.989 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-upload-enclosure/u-upload-enclosure.vue' in 'D:\ideaWorkSpace\ehl-wx\applicationCenter\examine' 11:10:22.999 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-waterfall/u-waterfall.vue' in 'D:\ideaWorkSpace\ehl-wx\applicationCenter\examine' 11:10:23.006 Module not found: Error: Can't resolve '@/uni_modules/uview-ui/components/u-waterfall/u-waterfall.vue' in 'D:\ideaWorkSpace\ehl-wx\applicationCenter\knowledgeBase'解决
07-14
这些错误提示表明在指定的路径找不到相应的文件。根据错误信息,文件路径应该是 `@/uni_modules/uview-ui/components/u-cell-item/u-cell-item.vue`、`@/uni_modules/uview-ui/components/u-mask/u-mask.vue`、`@/uni_modules/uview-ui/components/u-section/u-section.vue` 等等。 要解决这个问题,你可以尝试以下几个步骤: 1. 确保你安装了uview-ui组件库,并且已经按照官方文档的要求进行了配置。你可以使用 `npm install uview-ui` 命令来安装uview-ui。 2. 检查你的文件路径是否正确。确保文件路径的 `@` 符号是正确的,并且文件名的大小写与实际文件名匹配。 3. 确保你在项目正确导入了需要使用的组件。检查你的代码是否存在类似以下的导入语句: ```javascript import UCellItem from '@/uni_modules/uview-ui/components/u-cell-item/u-cell-item.vue'; import UMask from '@/uni_modules/uview-ui/components/u-mask/u-mask.vue'; import USection from '@/uni_modules/uview-ui/components/u-section/u-section.vue'; // 其他组件的导入语句... ``` 4. 如果以上步骤都没有解决问题,可以尝试检查uview-ui组件库的版本和你当前项目的版本是否兼容。有时候不同版本之间可能会有文件路径或组件名的变化,需要进行相应的调整。 如果问题仍然存在,建议查看uview-ui的官方文档或在相关社区寻求帮助,以获取更详细的解决方案。同时,提供更多关于你的项目配置和代码的信息,也有助于我提供更准确的帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

P P PHP

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值