-
Notifications
You must be signed in to change notification settings - Fork 12k
Closed
Description
Expected Behavior
determineDataLimits is an expensive calculation, and should only be called when needed. If a graph has two axes, determineDataLimits should only be called twice per update.
Current Behavior
determineDataLimits is called five times per update:
- twice during
getMinimumBoxSize - twice during
fitBox - once during
finalFitVerticalBox
Possible Solution
Perhaps we could cache the result of determineDataLimits, or ideally refine the chart update lifecycle to not require a scale to be updated at each of the stages mentioned above.
Steps to Reproduce (for bugs)
- Create a chart with two axes
- Add a dataset to the chart
- Update the dataset
Context
determineDataLimits is quite an expensive function. It could also be optimised, but the first step would be to remove duplicate calculations. In my performance tests, each subsequent identical call to determineDataLimits is faster due to JIT optimisations, but this is reliant on the underlying engine to optimise things.
Environment
- Chart.js version: 2.7.2
- Browser name and version: Chrome