Skip to content

Conversation

bernardobelchior
Copy link
Member

@bernardobelchior bernardobelchior commented Jun 6, 2025

Part of #15383.

Screen.Recording.2025-06-27.at.09.25.44.mov

Border radius in bar charts

For now, bar chart preview does not show a border radius. Zoom only makes sense for a lot of data; in that case, the border radius is barely visible.

This can be implemented if we feel there's a use case where it would make sense.

Handling slots

At the moment, we aren't handling slots. Slots are provided by prop to BarElement and LineElement, and we aren't providing them, so there is no way to customize the preview rendering using slots.

It's still possible to customize the preview by also personalizing the main chart, as those props will apply to both the main and the preview charts.

Still not sure how to handle slots for the preview: should we use specific slots or the same as the main chart? Should we allow customizing at all?

Animation

Decided not to animate the preview. We can do it later, if needed.

@bernardobelchior bernardobelchior added type: new feature Expand the scope of the product to solve a new problem. scope: charts Changes related to the charts. labels Jun 6, 2025
@mui-bot
Copy link

mui-bot commented Jun 6, 2025

Deploy preview: https://deploy-preview-18267--material-ui-x.netlify.app/

Updated pages:

Bundle size report

Total Size Change: 🔺+104KB(+0.78%) - Total Gzip Change: 🔺+33.6KB(+0.83%)
Files: 122 total (0 added, 0 removed, 37 changed)

Show details for 100 more bundles (22 more not shown)

@mui/x-charts-pro/ChartZoomSliderparsed: 🔺+37.2KB(+54.04%) gzip: 🔺+11.3KB(+46.48%)
@mui/x-charts-pro/ScatterChartProparsed: 🔺+29.3KB(+12.29%) gzip: 🔺+9.52KB(+12.72%)
@mui/x-charts-pro/BarChartProparsed: 🔺+20.7KB(+8.19%) gzip: 🔺+6.59KB(+8.32%)
@mui/x-charts-pro/LineChartProparsed: 🔺+10.3KB(+3.82%) gzip: 🔺+3.7KB(+4.42%)
@mui/x-charts-proparsed: 🔺+5.38KB(+1.43%) gzip: 🔺+1.59KB(+1.40%)
@mui/x-charts/ScatterChartparsed: 🔺+88B(+0.05%) gzip: 🔺+281B(+0.47%)
@mui/x-chartsparsed: 🔺+82B(+0.03%) gzip: 🔺+57B(+0.06%)
@mui/x-charts-pro/ChartContainerProparsed: 🔺+61B(+0.03%) gzip: 🔺+25B(+0.05%)
@mui/x-charts-pro/ChartDataProviderProparsed: 🔺+61B(+0.04%) gzip: 🔺+26B(+0.05%)
@mui/x-charts-pro/ChartsToolbarProparsed: 🔺+61B(+0.09%) gzip: 🔺+27B(+0.11%)
@mui/x-charts-pro/FunnelChartparsed: 🔺+61B(+0.03%) gzip: 🔺+28B(+0.04%)
@mui/x-charts-pro/Heatmapparsed: 🔺+61B(+0.03%) gzip: 🔺+28B(+0.04%)
@mui/x-charts-pro/PieChartProparsed: 🔺+61B(+0.03%) gzip: 🔺+29B(+0.04%)
@mui/x-charts-pro/RadarChartProparsed: 🔺+61B(+0.03%) gzip: 🔺+28B(+0.04%)
@mui/x-charts/BarChartparsed: 🔺+61B(+0.03%) gzip: 🔺+22B(+0.03%)
@mui/x-charts/ChartsAxisparsed: 🔺+61B(+0.09%) gzip: 🔺+29B(+0.11%)
@mui/x-charts/ChartsAxisHighlightparsed: 🔺+61B(+0.10%) gzip: 🔺+27B(+0.12%)
@mui/x-charts/ChartsGridparsed: 🔺+61B(+0.10%) gzip: 🔺+29B(+0.14%)
@mui/x-charts/ChartsLegendparsed: 🔺+61B(+0.08%) gzip: 🔺+25B(+0.10%)
@mui/x-charts/ChartsReferenceLineparsed: 🔺+61B(+0.10%) gzip: 🔺+28B(+0.13%)
@mui/x-charts/ChartsSurfaceparsed: 🔺+61B(+0.10%) gzip: 🔺+27B(+0.13%)
@mui/x-charts/ChartsTooltipparsed: 🔺+61B(+0.08%) gzip: 🔺+26B(+0.10%)
@mui/x-charts/ChartsXAxisparsed: 🔺+61B(+0.09%) gzip: 🔺+28B(+0.11%)
@mui/x-charts/ChartsYAxisparsed: 🔺+61B(+0.09%) gzip: 🔺+22B(+0.09%)
@mui/x-charts/Gaugeparsed: 🔺+61B(+0.04%) gzip: 🔺+28B(+0.06%)
@mui/x-charts/LineChartparsed: 🔺+61B(+0.03%) gzip: 🔺+31B(+0.04%)
@mui/x-charts/PieChartparsed: 🔺+61B(+0.03%) gzip: 🔺+27B(+0.04%)
@mui/x-charts/RadarChartparsed: 🔺+61B(+0.03%) gzip: 🔺+27B(+0.05%)
@mui/x-charts/SparkLineChartparsed: 🔺+61B(+0.03%) gzip: 🔺+30B(+0.05%)
@mui/x-charts/ChartContainerparsed: 🔺+60B(+0.04%) gzip: 🔺+28B(+0.06%)
@mui/x-charts/ChartDataProviderparsed: 🔺+60B(+0.04%) gzip: 🔺+27B(+0.06%)
@mui/x-data-gridparsed: ▼-44B(-0.01%) gzip: ▼-9B(-0.01%)
@mui/x-data-grid-premiumparsed: ▼-44B(-0.01%) gzip: ▼-13B(-0.01%)
@mui/x-data-grid-premium/DataGridPremiumparsed: ▼-44B(-0.01%) gzip: ▼-16B(-0.01%)
@mui/x-data-grid-proparsed: ▼-44B(-0.01%) gzip: ▼-11B(-0.01%)
@mui/x-data-grid-pro/DataGridProparsed: ▼-44B(-0.01%) gzip: ▼-14B(-0.01%)
@mui/x-data-grid/DataGridparsed: ▼-44B(-0.01%) gzip: ▼-12B(-0.01%)
@mui/x-charts/ChartsClipPathparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsLabelparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsLocalizationProviderparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsOverlayparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsTextparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/Toolbarparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickersparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-proparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterDateFnsparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterDateFnsJalaliparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterDayjsparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterLuxonparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterMomentparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterMomentHijriparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterMomentJalaaliparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/DateRangeCalendarparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/DateRangePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/DateRangePickerDayparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/DateRangePickerDay2parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/DateTimeRangePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/DesktopDateRangePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/DesktopDateTimeRangePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/DesktopTimeRangePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/LocalizationProviderparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/MobileDateRangePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/MobileDateTimeRangePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/MobileTimeRangePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/MultiInputDateRangeFieldparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/MultiInputDateTimeRangeFieldparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/MultiInputTimeRangeFieldparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/PickersRangeCalendarHeaderparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/SingleInputDateRangeFieldparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/SingleInputDateTimeRangeFieldparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/SingleInputTimeRangeFieldparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/StaticDateRangePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/TimeRangePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterDateFnsparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterDateFnsBaseparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterDateFnsJalaliparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterDayjsparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterLuxonparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterMomentparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterMomentHijriparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterMomentJalaaliparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/DateCalendarparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/DateFieldparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/DatePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/DateTimeFieldparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/DateTimePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/DayCalendarSkeletonparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/DesktopDatePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/DesktopDateTimePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/DesktopTimePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/DigitalClockparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/LocalizationProviderparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/MobileDatePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/MobileDateTimePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/MobileTimePickerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/MonthCalendarparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/MultiSectionDigitalClockparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/PickerDay2parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/PickersActionBarparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/PickersCalendarHeaderparsed: 0B(0.00%) gzip: 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 053fc71

Copy link

codspeed-hq bot commented Jun 6, 2025

CodSpeed Performance Report

Merging #18267 will not alter performance

Comparing bernardobelchior:chart-zoom-preview (053fc71) with master (c4abca2)

Summary

✅ 9 untouched benchmarks

Comment on lines 146 to 137
(_, params: { drawingArea: ChartDrawingArea; zoomMap: Map<AxisId, ZoomData> | undefined }) =>
params,
],
(axis, formattedSeries, seriesConfig, zoomOptions, getFilters, { drawingArea, zoomMap }) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(_, params: { drawingArea: ChartDrawingArea; zoomMap: Map<AxisId, ZoomData> | undefined }) =>
params,
],
(axis, formattedSeries, seriesConfig, zoomOptions, getFilters, { drawingArea, zoomMap }) =>
(_, drawingArea: ChartDrawingArea) => drawingArea,
(_, __, zoomMap: Map<AxisId, ZoomData> | undefined ) => zoomMap,
],
(axis, formattedSeries, seriesConfig, zoomOptions, getFilters, drawingArea, zoomMap) =>

This with the following modification, and a memorization of drawingArea should avoid re-rendering the review axes

-  const { axis: xAxis, axisIds: xAxisIds } = useSelector(store, selectorChartComputedXAxes, {
-     drawingArea,
-     zoomMap: undefined,
-  });
+  const { axis: xAxis, axisIds: xAxisIds } = useSelector(store, selectorChartComputedXAxes, drawingArea, undefined);

Since the zoom preview should not be zoomed itself, the are the zoomOptions, and getFilters needed?

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 16, 2025
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 16, 2025
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 17, 2025
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 26, 2025
@bernardobelchior bernardobelchior force-pushed the chart-zoom-preview branch 2 times, most recently from 3316cb0 to 3d131d3 Compare June 27, 2025 07:06
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 27, 2025
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 27, 2025
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 27, 2025
@bernardobelchior bernardobelchior marked this pull request as ready for review June 27, 2025 11:59
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jul 3, 2025
Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refinements in the demo looks great 🚀

Do you plan to solve the selector refinement in this PR or in a follow up?

id: 'x',
data: new Array(101).fill(null).map((_, i) => i),
label: 'Age',
valueFormatter: (v) => (v === 100 ? '100+' : `${v}`),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
valueFormatter: (v) => (v === 100 ? '100+' : `${v}`),
valueFormatter: (v) => (v === 100 ? '100+' : v.round().toString()),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should we round the age?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because of the zoom tooltip

d={d}
color={color}
gradientId={gradientId}
skipAnimation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why but animation is still visible

Capture.video.du.2025-07-03.09-42-48.mp4

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, figured it out. It's because we're rendering two clipPath with the same ID, so it's probably using the first one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it by creating a slimmed down version of AreaElement and LineElement for the preview.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, figured it out. It's because we're rendering two clipPath with the same ID, so it's probably using the first one.

NIce catch. Those duplicated ids make me crazy when I've to debug them 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The browser could at least warn if two elements have the same id 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should start using useId. Do we expect the clip path IDs to be stable? If we were to use useId, then we wouldn't have this problem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial idea was to use the useId to generate a unique id per chart. Then deriving all ids from this one.

It's not super useful, so fully open for other solution on this aspect

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deriving all ids from this one

Are we using it for anything?

If users can't set the ID, then it isn't reliable, so I'm failing to see the benefit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we use it. The only usecases I found in the docs are in the line Demo where we use useChartId() mostly because it's a convenient way to generate ids in the demo without relying on unstable imports.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without relying on unstable imports

Which unstable imports are you referring to?

@bernardobelchior
Copy link
Member Author

Do you plan to solve the selector refinement in this PR or in a follow up?

Do you mean this? I've just updated this in the last commit. Had some changes that I forgot to revert.

Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except the area valueFormatter everything looks good 👌 :

@bernardobelchior bernardobelchior merged commit 7875af8 into mui:master Jul 4, 2025
23 checks passed
@bernardobelchior bernardobelchior deleted the chart-zoom-preview branch July 4, 2025 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: charts Changes related to the charts. type: new feature Expand the scope of the product to solve a new problem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants