How to destroy chart before re-rendering?
See original GitHub issueExpected Behavior
I have a chart that can be rendered multiple times, for example as we change filter criteria.
Actual Behavior
When I do this, it seems like all the charts “stack up” underneath each other. This is very obvious when I move the mouse over the charts. The various charts that I’ve seen pop in and out as I drag the mouse over the chart.
What I’ve Done
I’m using this.renderChart(data, options)
to render each time the filter changes. Based upon information I’ve found through web searches, I tried usingthis._chart.destroy()
before calling renderChart()
but that produces a browser console error saying destroy()
doesn’t exist.
Environment
- vue.js version: 2.4.4
- vue-chart.js vsion: 3.0.0
- npm version: 5.3.0
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
React & Chartjs: How can I best destroy my chart when re ...
1 Answer 1 · Declare chart variable outside of class component · Run the build chart fn on both componentDidMount & componentDidUpdate ·...
Read more >How to use chart destroy API and render new chart in Chart JS
How to use chart destroy API and render new chart in Chart JSIn this video we will explore how to use chart destroy...
Read more >How to destroy chart.js chart in lightning component
Hi, Place the canvas tag inside any div tag. First time you can successfully draw the chart on the canvas .Next time when...
Read more >[Solved]-How to clear/destroy Chart.js canvas when the chart ...
I had problems with data and size changes on rerendering, and i found a way to force updating it using ref (profitChartRef.current.chartInstance.destroy();) ...
Read more >How to use chart destroy API and render new chart in Chart JS
In this case the destroy chart is a must use. We need to use chart.destroy() API to make the canvas a white slate...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sometimes
_chart
doesn’t exist yet, so using code like this seems to work:You can only access it inside your Chart component.