Skip to content

Add a way to skip animations on updates to a dataset #1006

Closed
@MaxboDev

Description

@MaxboDev

Would you like to work on this feature?

  • Check this if you would like to implement a PR, we are more than happy to help you go through the process.

What problem are you trying to solve?

I have a line chart where I want to be able to add data after its initially drawn. When I do that, it replays the initial animation where each point goes from 0 to its intended position but I'd like to avoid that.

In the chart.js docs it says that you can prevent animations by calling update with none as the mode here: https://www.chartjs.org/docs/latest/developers/updates.html#preventing-animations

But in the react-chartjs-2 code it looks like updates are always done without a value passed for mode

chartRef.current.update();

Describe the solution you'd like

It would be great if it was possible to specify the mode to update the chart with, or provide some other mechanism to say that you dont want to animate for a particular update.

Alternatively if anyone knows of a way I can achieve this with the current implementation that would be super helpful.

Describe alternatives you've considered

I tried setting animation duration to 0 when sending the updated data and then setting it back afterwards but that didn't seem to work as it still animated and felt pretty hacky. Maybe i could set the animation duration in one render and then update the data, then set the anaimation duration back to its original value? I haven't tried that but it feels even more hacky.

Documentation, Adoption, Migration Strategy

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions