[ECharts] There is a chart instance already initialized on the dom.

[ECharts] There is a chart instance already initialized on the dom.

 

 

报错解释:
这个错误表示在同一个DOM元素上已经初始化了一个ECharts图表实例,而你又尝试去在同一个DOM上初始化另一个图表实例。ECharts不允许在同一个DOM上叠加多个实例。

解决方法:
    在尝试初始化新的图表实例之前,首先销毁已经存在于该DOM上的实例。可以使用echarts.dispose方法来销毁实例:

if (echarts.getInstanceByDom(domElement)) {
    echarts.dispose(domElement);
}
var myChart = echarts.init(domElement);
// 其他初始化代码

    确保你的代码逻辑中不会重复初始化同一个DOM元素上的图表实例。
    如果你的应用逻辑需要多个图表实例,考虑使用不同的DOM元素或者通过ECharts实例的setOption方法来更新现有实例的配置,而不是重新初始化。

 

Uncaught ReferenceError: domElement is not defined

this.$refs.echarts1

 

解决:

 this.intervalId = setInterval(() => {

        if (echarts.getInstanceByDom(this.$refs.echarts1)) {
            echarts.dispose(this.$refs.echarts1);
        }
        if (echarts.getInstanceByDom(this.$refs.echarts2)) {
            echarts.dispose(this.$refs.echarts2);
        }
        this.loadData();

      }, 10000) 

 

 

 

this.intervalId = setInterval
 
  beforeDestroy() {
    clearInterval(this.intervalId)
  }
 

 

 const myChart1 = echarts.init(this.$refs.echarts1)

 const myChart2 = echarts.init(this.$refs.echarts2)

 

[ECharts] Can't get DOM width or height. Please check dom.clientWidth and dom.clientHeight. They should not be 0.For example, you may need to call this in the callback of window.onload.

 

 

 

posted @   emanlee  阅读(721)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
历史上的今天:
2021-09-27 MyBatis中的OGNL教程
2021-09-27 Java中的几种实体类对象(PO,VO,DAO,BO,POJO)
2019-09-27 Android Studio 开发
点击右上角即可分享
微信分享提示