mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[WIP][charts-pro] Chart zoom preview

Open bernardobelchior opened this issue 7 months ago • 3 comments

TODO:

  • [x] Add line plot
  • [x] Add area plot
  • [x] Add bar plot
  • [x] Handle y axes
  • [ ] How to handle slots?
  • [ ] Should we animate?
  • [x] Handle tick label overflow into slider preview

bernardobelchior avatar Jun 06 '25 12:06 bernardobelchior

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 :no_entry_sign: dangerJS against 053fc71ba1a60ff65e51bce275d98fe72cd681f2

mui-bot avatar Jun 06 '25 12:06 mui-bot

CodSpeed Performance Report

Merging #18267 will not alter performance

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

Summary

✅ 9 untouched benchmarks

codspeed-hq[bot] avatar Jun 06 '25 12:06 codspeed-hq[bot]

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

github-actions[bot] avatar Jun 16 '25 10:06 github-actions[bot]

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

github-actions[bot] avatar Jun 17 '25 14:06 github-actions[bot]

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

github-actions[bot] avatar Jun 26 '25 14:06 github-actions[bot]

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

github-actions[bot] avatar Jun 27 '25 09:06 github-actions[bot]

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

github-actions[bot] avatar Jun 27 '25 13:06 github-actions[bot]

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

github-actions[bot] avatar Jun 30 '25 11:06 github-actions[bot]

Just a first comment before reviewing the code. The design and the interaction looks nice.

But the y-axis for the line chart and the two axes for the scatter look weird. If I had te create a visualisation for a website I would

  • for the line chart do not put a y-axis preview:

    • either a zoom filtering
    • or the range but without showing its content for UI consistency with the x-axis. Something a bit like that image
  • for the scatter chart: either the same idea of removing the content preview, or at least drastically decrease the mark size in the preview (here is a comparison of the x-axis with a marksize of 1px compared to the current one (4px). IMO the first one looks more professional

image image

alexfauquette avatar Jul 01 '25 08:07 alexfauquette

Oh yeah, I thought about this too, forgot to mention

  • for the scatter chart: either the same idea of removing the content preview, or at least drastically decrease the mark size in the preview (here is a comparison of the x-axis with a marksize of 1px compared to the current one (4px). IMO the first one looks more professional

JCQuintas avatar Jul 01 '25 09:07 JCQuintas

Should we turn on preview on perf benchmark?

alexfauquette avatar Jul 01 '25 10:07 alexfauquette

Should we turn on preview on perf benchmark?

Hm, might be a good idea. Or create a new benchmark. I'll look into it.

bernardobelchior avatar Jul 01 '25 15:07 bernardobelchior

Just a first comment before reviewing the code. The design and the interaction looks nice.

But the y-axis for the line chart and the two axes for the scatter look weird. If I had te create a visualisation for a website I would

  • for the line chart do not put a y-axis preview:

    • either a zoom filtering
    • or the range but without showing its content for UI consistency with the x-axis. Something a bit like that image

I wanted to ensure the preview is exactly like the main chart. Maybe this is a default we can flip once we add configuration?

preview: { axisIds: ['x'] } // By default, only includes x-axes

What do you think?

  • for the scatter chart: either the same idea of removing the content preview, or at least drastically decrease the mark size in the preview (here is a comparison of the x-axis with a marksize of 1px compared to the current one (4px). IMO the first one looks more professional

Do you mean removing the content preview on both axes?

Again, same argument as before: I wanted to maintain the preview similar to the main chart. I agree the second option looks better, but if we override the marker size, IMO we should allow customizing.

Maybe adding a section to the docs explaining how to customize the circle size would be enough?

bernardobelchior avatar Jul 01 '25 15:07 bernardobelchior

I wanted to maintain the preview similar to the main chart.

I think this is the root of our diverging point of view. For me a "preview"(maybe "overview" is closer to the point) should be like a summary. A summary is not as beautiful or as detailed as the original. But it's practical. It cuts detailed to bring as much value in a constraint space.

That resume the two point I made about docs

  • The line chart y-axis preview brings low value to the user. The only thing we can read from it is the min/max of the charts. But this information is already available in the slider
  • The scatter chart can bring a bit of value by showing where in the zoom de we have groups of points. But the bigger the dots are, the less informative it is because they are hiding each other. Basically you know where points are, but lose the notion of density. That's why I propose to preview smaller point by default, and let an option for user to make them bigger

alexfauquette avatar Jul 01 '25 20:07 alexfauquette

The line chart y-axis preview brings low value to the user. The only thing we can read from it is the min/max of the charts. But this information is already available in the slider

Are you saying we should disable the y-axis preview in the demo, then? I think that makes sense.

If you meant that the y-axis preview should not render the data points, then I'm not sure. If users don't want to see the preview, then they can disable it. What's the benefit of not rendering the data points?

The scatter chart can bring a bit of value by showing where in the zoom de we have groups of points. But the bigger the dots are, the less informative it is because they are hiding each other. Basically you know where points are, but lose the notion of density. That's why I propose to preview smaller point by default, and let an option for user to make them bigger

Makes sense. I'll reduce the default marker size and add an option in a follow-up PR.

bernardobelchior avatar Jul 02 '25 08:07 bernardobelchior

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

github-actions[bot] avatar Jul 02 '25 15:07 github-actions[bot]

Are you saying we should disable the y-axis preview in the demo, then? I think that makes sense.

Yes, we can have the option to display it. But not use it in this docs exemple

alexfauquette avatar Jul 02 '25 15:07 alexfauquette

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

github-actions[bot] avatar Jul 02 '25 19:07 github-actions[bot]

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.

bernardobelchior avatar Jul 03 '25 08:07 bernardobelchior