Skip to content

[BUG] determineDataLimits called five times per update #5389

@veggiesaurus

Description

@veggiesaurus

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)

  1. Create a chart with two axes
  2. Add a dataset to the chart
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions