Skip to content

[charts-pro] Allow sampling on non-zoomable charts#23051

Merged
JCQuintas merged 3 commits into
mui:masterfrom
JCQuintas:feat/charts-sampling-non-zoom
Jul 8, 2026
Merged

[charts-pro] Allow sampling on non-zoomable charts#23051
JCQuintas merged 3 commits into
mui:masterfrom
JCQuintas:feat/charts-sampling-non-zoom

Conversation

@JCQuintas

Copy link
Copy Markdown
Member

Follow-up from #22830. Closes #23031.

Problem

Sampling was coupled to zoom: both plot hooks gated on the axis zoom entry and sample() returned null when 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 sampling is enabled on an axis without zoom, sample at the full range (span 100%), still bounded by MAX_RENDERED_POINTS — mirroring the full-range sampling the zoom-slider preview already uses.

  • New getFullRangeZoom(axisId) helper ({ start: 0, end: 100 }).
  • useLinePlotData / useBarPlotData fall back to it when the axis has no active zoom.
  • selectorChartHighlightBucketSize un-gated from zoom so the axis highlight also widens over merged buckets on static charts.

Open questions (from the issue)

  • Separate opt-in flag? No. The sampling prop is already independent of zoom; enabling it alone opts in.
  • Non-zoom defaults? minSpan 0, 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 BarChartPro and LineChartPro.

Docs

performance.md updated: sampling applies to static charts too, not only zoomable ones.

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
@JCQuintas
JCQuintas requested a review from alexfauquette as a code owner July 3, 2026 12:45
@JCQuintas JCQuintas self-assigned this Jul 3, 2026
@JCQuintas JCQuintas added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. scope: charts Changes related to the charts. plan: Pro Impact at least one Pro user. labels Jul 3, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Jul 3, 2026

Copy link
Copy Markdown

Deploy preview

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 🔺+88B(+0.02%) 🔺+55B(+0.05%)
@mui/x-charts-pro 🔺+88B(+0.02%) 🔺+22B(+0.01%)
@mui/x-charts-premium 🔺+88B(+0.01%) 🔺+69B(+0.04%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-scheduler 0B(0.00%) 0B(0.00%)
@mui/x-scheduler-premium 0B(0.00%) 0B(0.00%)
@mui/x-chat 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

Comment thread packages/x-charts-pro/src/LineChartPro/LineChartPro.sampling.test.tsx Outdated
@JCQuintas
JCQuintas enabled auto-merge (squash) July 8, 2026 08:43
@JCQuintas
JCQuintas merged commit 110c580 into mui:master Jul 8, 2026
20 of 21 checks passed
@JCQuintas
JCQuintas deleted the feat/charts-sampling-non-zoom branch July 8, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plan: Pro Impact at least one Pro user. scope: charts Changes related to the charts. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[charts-pro] Allow sampling on non-zoomable charts

2 participants