Skip to content

fix(DatasetController): skip hidden datasets to improve performance#12183

Open
WAGHMARETANNU wants to merge 3 commits intochartjs:masterfrom
WAGHMARETANNU:master
Open

fix(DatasetController): skip hidden datasets to improve performance#12183
WAGHMARETANNU wants to merge 3 commits intochartjs:masterfrom
WAGHMARETANNU:master

Conversation

@WAGHMARETANNU
Copy link

Summary

This PR addresses issue #12179: "Charts with a large number of hidden datasets perform poorly".

When many datasets are present and most are hidden, Chart.js was still performing expensive parsing, stacking, and min/max calculations for hidden datasets. This caused noticeable lag in scenarios like time-tracking charts with 50+ datasets.

Changes

  • _resyncElements now skips processing for datasets where meta.hidden === true.
  • getMinMax returns { min: Infinity, max: -Infinity } for hidden datasets, avoiding unnecessary calculations.
  • Minor refactoring to ensure that hidden datasets do not affect stacks or parsing loops.

Benefits

  • Significant performance improvement for charts with many datasets where only a subset is visible.
  • Reduces CPU usage and lag in common use cases such as toggling dataset visibility.
  • Maintains correct functionality for visible datasets and stacked charts.

Test

  • Verified charts with multiple hidden datasets no longer experience lag on updates.
  • All existing unit tests pass, and no visual regressions observed.

Issue

Closes #12179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Charts with a large number of hidden datasets perform poorly

1 participant