[charts] Optimize and de-duplicate sampled axis-highlight band lookup#23052
Merged
alexfauquette merged 3 commits intoJul 7, 2026
Merged
Conversation
Extract the band-widening logic shared by the X and Y axis highlights into a single getSampledBandHighlight helper, and resolve the band index via the highlight state's dataIndex (O(1)) instead of data.indexOf (O(N)). Closes mui#23029
Deploy previewhttps://deploy-preview-23052--material-ui-x.netlify.app/Bundle size
PerformanceTotal duration: 2,327.73 ms 🔺+453.97 ms(+24.2%) | Renders: 63 (+0)
…and 9 more (+12 within noise) — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
Reading dataIndex via destructuring in the map callback signature broke under the charts-pro union type. Access it off the item instead.
alexfauquette
approved these changes
Jul 4, 2026
Merged
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up from #22830.
The bucket-widened axis highlight (
ChartsXAxisHighlight.tsx/ChartsYAxisHighlight.tsx) had two issues, both addressed here:data.indexOf(value)(O(N)). The highlight state already carriesdataIndex, so we use it directly. Adata.indexOffallback is kept for the case wheredataIndexis unavailable.if (bucketSize > 1) …band-widening logic was duplicated between the X and Y highlight components. Extracted into a sharedgetSampledBandHighlight({ scale, value, dataIndex, data, bucketSize }) => { bandStart, bandSize }helper.Reversed-axis correctness is out of scope (tracked in #22997).
Closes #23029