question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There is a chart instance already initialized on the dom

See original GitHub issue

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 [其他信息]

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
FishYu99commented, Oct 5, 2017

參考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({....});
2reactions
pissangcommented, Jun 6, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

There is a chart instance already initialized on the dom. #299
I just created one chart and get this warning on console: There is a chart instance already initialized on the dom. (echarts.js:2168) I...
Read more >
There is a chart instance already initialized on the dom!
On the current page, when you execute charts drawing for many times, the console will give a warning “there is a chart instance...
Read more >
There is a chart instance already initialized on the dom!警告
用echarts时,如果存在DOM,就会报存在警告,处理方法删除DOM: echarts.dispose(document.getElementById(id)) 复制代码.
Read more >
Echarts:There is a chart instance already initialized ... - 零五网
使用Echarts 插件的时候,多次加载会出现 There is a chart instance already initialized on the dom! 错误,提示echarts 已经初始化过了。
Read more >
echart cannot be visualized on DOM even though there is an ...
Hello i have a wird issue that the echarts is not loading even there is an instance on the DOM. ... chart displayed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found