You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Re-rendering plot when any state of the component changes #648
This behaviour was not observed with older version of chartjs. i.e version less than 3. When ever the state of the component changes , entire plot re renders again as if it is rendering for the first time. sample code to this behaviour is here
@vaasu070 I have released a test package that solves this problem. Could I ask to try it out. And if everything is OK, I will release a minor version with an edit.
@YakovlevCoded , I observed one more issue with test-react-chartjs-2 package, whenever data is updated, the chart fails to show the new data. It is always showing the initial data. This can be observed here . Hope this will be addressed soon. Thanks
changed the title [-]Re-rendering plot when the any state of the component changes[/-][+]Re-rendering plot when any state of the component changes[/+]on Apr 29, 2021
@YakovlevCoded A new version 3.0.3 is rolled out, But the above bug still exists in it here. If its not too early to ask, when it will be fixed and released? Its quite critical for out project Thanks.
The above happens on all chart types whether or not the state is passed to the component or not. (in other words, taking rotation out of the options objects still results in the same re-rendering behavior)
I'm using the following patch as a band-aid until the issue is fixed properly. This probably does not cover all use-cases (it definitely doesn't handle datasets being removed from the chart), but it works for me with a simple bar chart that is refreshed every second:
Hey, is there any update on this issue? Its quite a major problem for us and I'm wondering whether we'll have to switch to using chart.js directly before we go live. Thanks
Just to help clarify things for anyone reading this thread, it looks like this issue is fixed in 3.0.5. @YakovlevCoded it can probably be closed unless anyone has an issue after upgrading to 3.0.5.
Reacted by Zac, Jordan LaPointe, Derek Shu and David Gourevitch
@larinius - this might be a little late - but I just spent a week wracking my brain over performance issues rendering pages with multiple charts with very large datasets constantly re-rendering every time the parent stat changed - slowing down my entire page.... React memo solved my issue - basically made my child components with the chartjs components no re render every time the parent does, only when its down state or props change
Reacted by Muhammad-Tahir Sanuth and Dao Van Tien Quyen
@larinius - React memo solved my issue - basically made my child components with the chartjs components no re render every time the parent does, only when its down state or props change
Can you post sample code with useMemo and react-chartjs-2 chart improvements?
@wayneschuller Thanks to @awhite9's suggestion, I fixed the re-rendering issue in react-chartjs-2 v5.3.0 and Chart.js v4.4.9 using useMemo. Here's a code sample; hope it helps others.
// React componentconstdata=prepareYourDataHere(props.rawData)// use useMemo to 'cache' the chart dataconstdataMemo=useMemo(()=>{returndata},[props.rawData])return(<divstyle={{width: '100%',}}><Bardata={dataMemo}options={options}plugins={[]}/></div>)
Activity
YakovlevCoded commentedon Apr 22, 2021
Yeah, thanks. i will work with it issue.
YakovlevCoded commentedon Apr 22, 2021
@vaasu070 I have released a test package that solves this problem. Could I ask to try it out. And if everything is OK, I will release a minor version with an edit.
vaasu070 commentedon Apr 23, 2021
@YakovlevCoded yeah now It is working as expected. Thanks for looking into it.
vaasu070 commentedon Apr 24, 2021
@YakovlevCoded , I observed one more issue with test-react-chartjs-2 package, whenever data is updated, the chart fails to show the new data. It is always showing the initial data. This can be observed here . Hope this will be addressed soon. Thanks
YakovlevCoded commentedon Apr 24, 2021
@vaasu070 Thank you! I will work on it.
[-]Re-rendering plot when the any state of the component changes[/-][+]Re-rendering plot when any state of the component changes[/+]vaasu070 commentedon Apr 29, 2021
@YakovlevCoded A new version 3.0.3 is rolled out, But the above bug still exists in it here. If its not too early to ask, when it will be fixed and released? Its quite critical for out project Thanks.
YakovlevCoded commentedon Apr 29, 2021
@vaasu070 If it's critical I'll try to finish it in the next couple of days. I'll let you know as soon as I'm done with this.
vaasu070 commentedon Apr 30, 2021
Would really appreciate this!
revroad-dev commentedon May 6, 2021
The re-rendering still seems to be an issue on current version 3.0.3. This was not an issue in chart.js v2.9.4
When the state changes the doughnut is redrawn/reanimated. Desired behavior is to rotate the doughnut without redrawing the graph.
revroad-dev commentedon May 6, 2021
The above happens on all chart types whether or not the state is passed to the component or not. (in other words, taking rotation out of the options objects still results in the same re-rendering behavior)
ntamas commentedon May 7, 2021
I'm using the following patch as a band-aid until the issue is fixed properly. This probably does not cover all use-cases (it definitely doesn't handle datasets being removed from the chart), but it works for me with a simple bar chart that is refreshed every second:
revroad-dev commentedon May 13, 2021
Hi @YakovlevCoded, thanks for all your hard work so far. Is this fix getting close to being released? Critical for our project.
maidinhkhoa92 commentedon May 19, 2021
I'm having same issue. Can I ask about release time ?
vaasu070 commentedon May 19, 2021
Hi @YakovlevCoded any update on this?
29 remaining items
MaxboDev commentedon Sep 27, 2021
Hey, is there any update on this issue? Its quite a major problem for us and I'm wondering whether we'll have to switch to using chart.js directly before we go live. Thanks
PCPbiscuit commentedon Sep 27, 2021
@M4sterShake Same here.
mssrmaps commentedon Sep 27, 2021
@PCPbiscuit @M4sterShake
me too
MaxboDev commentedon Sep 27, 2021
@PCPbiscuit @mssrmaps I've just tried upgrading to 3.0.5 and it fixed the issue for me. If you guys aren't on this version give it a go. Hope it works!
MaxboDev commentedon Oct 2, 2021
Just to help clarify things for anyone reading this thread, it looks like this issue is fixed in 3.0.5. @YakovlevCoded it can probably be closed unless anyone has an issue after upgrading to 3.0.5.
dangreen commentedon Oct 21, 2021
react-chartjs-2@v3.2.0 was released with rerendering improvements. So I'm closing this issue, but feel free to open new ones if any problems appear.
Elius94 commentedon May 2, 2022
For me the bug is still alive :( same as previous post says
dangreen commentedon May 2, 2022
@Elius94 Hi. Please open new issue with repoduction.
larinius commentedon Dec 8, 2022
Have exact same issue - re-rendering of donut chart when any app state changed. It looks very ugly and distracting.
"react-chartjs-2": "^5.0.1",
dangreen commentedon Dec 8, 2022
@larinius Hi. Please provide issue reproduction. You can fok codesandbox from examples.
awhite9 commentedon Jun 15, 2023
@larinius - this might be a little late - but I just spent a week wracking my brain over performance issues rendering pages with multiple charts with very large datasets constantly re-rendering every time the parent stat changed - slowing down my entire page.... React memo solved my issue - basically made my child components with the chartjs components no re render every time the parent does, only when its down state or props change
wayneschuller commentedon Dec 9, 2023
Can you post sample code with useMemo and react-chartjs-2 chart improvements?
quyendaoqt707 commentedon Jul 17, 2025
@wayneschuller Thanks to @awhite9's suggestion, I fixed the re-rendering issue in react-chartjs-2 v5.3.0 and Chart.js v4.4.9 using useMemo. Here's a code sample; hope it helps others.