[charts-pro] Allow sampling on non-zoomable charts#23051
Merged
Conversation
Sampling was gated on an axis zoom entry, so a static chart with a large dataset got no benefit. When sampling is enabled but the axis has no zoom, sample at full range (span 100%), still bounded by MAX_RENDERED_POINTS. Closes mui#23031
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
alexfauquette
approved these changes
Jul 7, 2026
…est.tsx Co-authored-by: Alexandre Fauquette <[email protected]> Signed-off-by: Jose C Quintas Jr <[email protected]>
JCQuintas
enabled auto-merge (squash)
July 8, 2026 08:43
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. Closes #23031.
Problem
Sampling was coupled to zoom: both plot hooks gated on the axis zoom entry and
sample()returnednullwhen there was no zoom. A static chart with a huge dataset (e.g. 1M points on a 500px canvas) got no benefit even though it can't be zoomed to resolve the detail.Fix
When
samplingis enabled on an axis without zoom, sample at the full range (span 100%), still bounded byMAX_RENDERED_POINTS— mirroring the full-range sampling the zoom-slider preview already uses.getFullRangeZoom(axisId)helper ({ start: 0, end: 100 }).useLinePlotData/useBarPlotDatafall back to it when the axis has no active zoom.selectorChartHighlightBucketSizeun-gated from zoom so the axis highlight also widens over merged buckets on static charts.Open questions (from the issue)
samplingprop is already independent ofzoom; enabling it alone opts in.minSpan0, span 100% — the screen rule (MIN_ELEMENT_SIZE_PX) plus the point cap drive the level, same as a zoomed full-range view.Tests
Regression tests (fail without the fix): static-axis sampling for both
BarChartProandLineChartPro.Docs
performance.mdupdated: sampling applies to static charts too, not only zoomable ones.