new Chart() after destroy() doesn't recreate responsive wrapper
See original GitHub issueProblem observed building an SPA. Running
var chart = new Chart(ctx, {
options: {
responsive: true
}
})
will create an initial chart wiht this structure:
div (my wrapper)
div.chartjs-size-monitor
canvas.chartjs-render-monitor
Then
chart.destroy();
chart = new Chart(ctx, {
options: {
responsive: true
}
})
will miss the required resizer:
div (my wrapper)
canvas.chartjs-render-monitor
Potentially root cause can probably also be oberved when running
gulp unittest --inputs test/specs/core.controller.tests.js --watch
and then updating core.controller.tests.js
. Not clearing the browser instance inbetween seems to have negative side effects, too.
Can no longer repro the last case.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
chart.js load totally new data - Stack Overflow
I had huge problems with this. First I tried .clear() then I tried .destroy() and I tried setting my chart reference to null....
Read more >Customizing Chart.JS in React - Bits and Pieces
We check if the chart was built previously. If so, we use the destroy() method before we create our chart.
Read more >[Solved]-Set an array to be displayed at Chart js-Chart.js
The easiest way would be to just destroy the chart (using the chart variable) and construct a new chart using the new data....
Read more >angular-chart-new - npm Package Health Analysis - Snyk
destroy() on the chart; $resize : call .resize() on the chart. angular-chart.js emits the following events on the scope ...
Read more >Chart.js with Angular | andrew-flower.com
warning Modifying the original array of data will not update the array. After modifying the array, you would need to call the update()...
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
As workaround its sufficient to clear the wrapper node (which is also often recommended on SO):
Closing until I find a better test case.