Incubator-echarts: There is a chart instance already initialized on the dom

Created on 6 Jun 2017  ·  6Comments  ·  Source: apache/incubator-echarts

One-line summary [问题简述]

在VUE里用了多入口,但是按需引入echarts的,为什么会报There is a chart instance already initialized on the dom.

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]:
  • Browser version [浏览器类型和版本]:
  • OS Version [操作系统类型和版本]:

Expected behaviour [期望结果]

ECharts option [ECharts配置项]


option = {

}

Other comments [其他信息]


Most helpful comment

dom 已经实例化过了,返回的是之前的实例,可以先 dispose 再重新实例化

All 6 comments

dom 已经实例化过了,返回的是之前的实例,可以先 dispose 再重新实例化

请问dispose应该在什么时间点调用?我需要在一个里画多个图表。

同问,如果要在一个页面上渲染多个图标,该怎么 init 呢?

这个怎么解决的

楼上有找到解决方法吗?分享一下呗

參考API文檔
http://echarts.baidu.com/api.html#echarts.dispose

1.取得DOM

let main = document.getElementById("main");

2.判斷是否已有實例

let existInstance = echarts.getInstanceByDom(main);
if (existInstance) {
    if (true) {
        echarts.dispose(chartStudent);
    }
}

3.初始化&配置設定

let mychart = echarts.init(main);
mychar.setOption({....});
Was this page helpful?
0 / 5 - 0 ratings