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

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 just update options. I’m on Ionic (Angular) and show this chart on page navigation. But this is not the problem. I get this warning only once or twice (directly at the same time).

image

If I navigate back and then forward again to the page with the chart, there is no more warning. Only the two (or sometimes only one) message you see above.

On ngOnChanges I reassign the chart options like this.options = {...this.options} to trigger an update. Any idea? …

{
    "echarts": "^5.0.2",
    "ngx-echarts": "^6.0.1",
}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
MukeshS-hexawarecommented, Nov 8, 2021

Instead of updating the object passed to [options], you can define the changing data in a separate variable and pass that variable to [merge].

Example:

HTML:

<div echarts [options]="gaugeCommonOptions" [merge]="cpuLoadChartOptions"></div>

Component:

@Component()
export class MyComponent {
  gaugeCommonOptions: EChartsOption = {
    series: [
      {
        type: 'gauge',
      }
    ]
  }
  cpuLoadChartOptions: EChartsOption = {};

  plotCpuLoad(): void {
    this.cpuLoadChartOptions = {series: [{data: [100]}]}
  }
}
0reactions
apoorv-2204commented, Mar 2, 2022

?

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
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 >
Echarts:There is a chart instance already initialized ... - 零五网
使用Echarts 插件的时候,多次加载会出现 There is a chart instance already initialized on the dom! 错误,提示echarts 已经初始化过了。
Read more >
消除There is a chart instance already initialized on the dom ...
消除There is a chart instance already initialized on the dom. React中使用echarts 注意事项.
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