react-chartjs-2 icon indicating copy to clipboard operation
react-chartjs-2 copied to clipboard

Timeseries update animation

Open Slind14 opened this issue 8 years ago • 7 comments

Hi there, how can we make use of this https://github.com/chartjs/Chart.js/pull/3399 ? It is listening to array modifications like push, shift... Since we are using react state I wonder how we can make this work.

Slind14 avatar Sep 08 '18 05:09 Slind14

Could you elaborate on the behavior your experiencing versus what you would expect? I'm dealing with some animation issues of my own and am curious if they're related.

buddyp450 avatar Sep 18 '18 15:09 buddyp450

No answer in a couple of months closing

jerairrest avatar Dec 27 '18 05:12 jerairrest

Sorry @jerairrest it would be great if it could be reopened.

Basically chart.js supports real time updates for timeseries data. This means that it does a different animation of moving the line/bars on the x axis instead of the new data animation. Chart.js is looking for array modification (push, pull...), unfortunately this is impossible to achieve due to the use of react state.

Slind14 avatar Dec 27 '18 06:12 Slind14

Interesting. This will require further investigation.

jerairrest avatar Dec 27 '18 06:12 jerairrest

Any update here? I'm also not able to create a live data experience with react due to this.

mjrcmrma avatar Apr 26 '19 09:04 mjrcmrma

Same problem here. I'm currently updating data by setting state in componentWillReceiveProps(). Props are passed from the parent component each time it calls API. Unfortunately, this blocks animation to work at all.

When the initial state is loaded to component and no state update is performed animation works fine. What is perhaps interesting I can still update labels dynamically, but when trying to update data - animation breaks.

#Edit: this is actually happening only with Line component, when using Doughnut component I'm updating state the same way and animation is working. I was able to solve issue thanks to the second suggestion by https://github.com/jerairrest/react-chartjs-2/issues/269#issuecomment-387349034 But this is not a very clean solution, so I'm still waiting for some update on this :)

#Edit: react-chartjs-2 @2.7.6

devstarman avatar May 02 '19 15:05 devstarman

Please try the latest react-chartjs-2 version - if the issue is still relevant, please open a new issue.

dangreen avatar Oct 26 '21 16:10 dangreen