Problem with redraw and destroy
i have the same problem, I have added redraw property to true , Without redraw property my chart works fine, but when i dynamically add data to chart, it draws chart in wierd ways, basically few labels from x-axis is still left over , even when they are not there in new data. I was hoping redraw would fix it, but it gives error. I think it may be a bug in redraw , it is not destroying the chart before redrawing
Originally posted by @kabeer10395 in https://github.com/reactchartjs/react-chartjs-2/issues/675#issuecomment-879675154
I also have the same problem, it bugs me that the chart is only updated after the second attempt of generating it. It means that when I am generating Chart 8, it shows Chart 7 and so on.
Issue is replicated here: https://codesandbox.io/s/crazy-curran-obsg2?file=/src/App.jsx
I am getting the same issue with the redraw. Any update on this ?
@mmtmr Did you get any solution regarding this ?
Issue is replicated here: https://codesandbox.io/s/crazy-curran-obsg2?file=/src/App.jsx
@mmtmr Hi. In your example there are no rendered charts, can you fix it?
Issue is replicated here: https://codesandbox.io/s/crazy-curran-obsg2?file=/src/App.jsx
@mmtmr Hi. In your example there are no rendered charts, can you fix it?
Sorry, I have fixed it already.
Pls
Hi, i've tried but can't fix my problem that is like your problem. Have another solution to use redraw?
@mmtmr Did you get any solution regarding this ?
Hi, i've tried but can't fix my problem that is like your problem. Have another solution to use redraw?
Sorry I did not, that's why I am also waiting for a fix here. Maybe you can try implementing states as stated here.
https://codesandbox.io/s/crazy-curran-obsg2?file=/src/App.jsx
@mmtmr Your example is still empty. Please make issue reproduction - it will help us to find the problem and fix it.

https://codesandbox.io/s/crazy-curran-obsg2?file=/src/App.jsx
@mmtmr Your example is still empty. Please make issue reproduction - it will help us to find the problem and fix it.
![]()
Sorry I also noticed that and was reproducing, I think it should work fine right now here.
@mmtmr Please try [email protected]
Works perfect . Thanks @dangreen
"react-chartjs-2": "~5.2.0"
I'm having this problem trying to render multiple charts in different tabs. The other tabs are not hidden, they are completely removed from the component tree with conditionals.
I can render all tabs with the same data just fine, but when I change one of the datasets I get:
Canvas is already in use. Chart with ID '0' must be destroyed before the canvas with ID 'Power' can be reused.
I would expect react-chartjs-2 to remove their canvas elements from the page when the react component that creates them is removed from the virtual dom. Is that how it works now or do I need to think about this differently?
Next morning and it got fixed first try. Apparently react-chartjs-2 uses some kind of shallow equality between props of different charts. I had a default dataset for testing of each graph. Once I created a function that spits out a new dataset object every time it instantly worked. (same looking object, just a new reference in memory.)
Maybe this comment will help a future searcher.
how was this problem fixed? can anyone help me since i am facing the same issue.
For me, the issue arose when I used the this method within a callback inside scales/x to truncate some characters from the labels in the options object.