Apply render optimizations when animation duration is 0
- Dominant language
- JavaScript
- Stars
- 67.7k
- Forks
- 11.9k
- Avg merge
- 7h 39m
- Merged PRs (30d)
- 5
Description
### Feature Proposal
My goal is to allow the same performance optimization that are applied when animations are disabled (i.e. with `options.animation = false`) or when using mode="none" (i.e. `chart.update('none')`) to animations with a duration of 0 (i.e. `options.animation.duration = 0`).
## Example context
Sometimes its desirable to only enable animations for certain situations. For example, you may want to generally disable most animations upon updates, but keep around animations for things like zooming (where the animation is more important to preserve context). As suggested in [the docs](https://www.chartjs.org/docs/latest/configuration/animations.html#disabling-animation), you can accomplish this with a setup like this:
```
const options = {
animations: { duration: 0 },
transitions: { zoom: { duration: 500 } },
}
```
Note that you cannot set `options.animations = false` or else all animations are disabled (including zoom).
In this situation, any chart update with a mode other than 'zoom' can equivalently run with `mode='none'` since the animations are disabled via duration=0. However, currently chartjs will still use the animation-based render, preventing certain performance optimizations in updaters (such as [dataset direct update](https://github.com/chartjs/Chart.js/blob/57b5c5b78fb2d8504f556bef6e4177735d9929ea/src/core/core.datasetController.js#L229) and [line controller direct update](https://github.com/chartjs/Chart.js/blob/57b5c5b78fb2d8504f556bef6e4177735d9929ea/src/controllers/controller.line.js#L84)). These performance optimizations can significantly speed up renders for large datasets (ex. 200ms -> 30ms).
### Possible Implementation
One options could be to detect in `chart.update()` if an update mode effectively has its animations disabled (via `duration=0`). In this event, mode could automatically be remapped to 'none' so downstream updates don't need to change their logic (ex. dataset and line controller both already support optimizing `mode='none'`).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.