Skip to content

Conversation

bernardobelchior
Copy link
Member

@bernardobelchior bernardobelchior commented Jul 10, 2025

Fixes #18758.

We'll now have a default onBeforeExport, which is exported as defaultOnBeforeExport.

This should allow users to customize the behavior of onBeforeExport while keeping our defaults (if they want to).

Screen.Recording.2025-07-10.at.16.39.08.mov

@bernardobelchior bernardobelchior 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. labels Jul 10, 2025
@mui-bot
Copy link

mui-bot commented Jul 10, 2025

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

Updated pages:

Bundle size report

Total Size Change: 🔺+1.94KB(+0.01%) - Total Gzip Change: 🔺+818B(+0.02%)
Files: 122 total (0 added, 0 removed, 28 changed)

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

@mui/x-charts-pro/ChartContainerProparsed: 🔺+600B(+0.33%) gzip: 🔺+259B(+0.45%)
@mui/x-charts-pro/ChartDataProviderProparsed: 🔺+600B(+0.34%) gzip: 🔺+253B(+0.46%)
@mui/x-charts-pro/FunnelChartparsed: 🔺+123B(+0.05%) gzip: 🔺+49B(+0.06%)
@mui/x-charts-proparsed: 🔺+111B(+0.03%) gzip: 🔺+42B(+0.04%)
@mui/x-charts-pro/Heatmapparsed: 🔺+88B(+0.04%) gzip: 🔺+22B(+0.03%)
@mui/x-charts-pro/PieChartProparsed: 🔺+88B(+0.04%) gzip: 🔺+28B(+0.04%)
@mui/x-charts-pro/RadarChartProparsed: 🔺+88B(+0.04%) gzip: 🔺+31B(+0.05%)
@mui/x-charts-pro/BarChartProparsed: 🔺+82B(+0.03%) gzip: 🔺+30B(+0.03%)
@mui/x-charts-pro/LineChartProparsed: 🔺+82B(+0.03%) gzip: 🔺+35B(+0.04%)
@mui/x-charts-pro/ScatterChartProparsed: 🔺+82B(+0.03%) gzip: 🔺+26B(+0.03%)
@mui/x-chartsparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts-pro/ChartsToolbarProparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts-pro/ChartZoomSliderparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/BarChartparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartContainerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartDataProviderparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsAxisparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsAxisHighlightparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsClipPathparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsGridparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsLabelparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsLegendparsed: 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/ChartsReferenceLineparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsSurfaceparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsTextparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsTooltipparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsXAxisparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsYAxisparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/Gaugeparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/LineChartparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/PieChartparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/RadarChartparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ScatterChartparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/SparkLineChartparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/Toolbarparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-data-gridparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-data-grid-premiumparsed: 0B(0.00%) gzip: 🔺+1B(0.00%)
@mui/x-data-grid-premium/DataGridPremiumparsed: 0B(0.00%) gzip: 🔺+2B(0.00%)
@mui/x-data-grid-proparsed: 0B(0.00%) gzip: 🔺+1B(0.00%)
@mui/x-data-grid-pro/DataGridProparsed: 0B(0.00%) gzip: 🔺+2B(0.00%)
@mui/x-data-grid/DataGridparsed: 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: 🔺+3B(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: 🔺+2B(+0.01%)
@mui/x-date-pickers-pro/DateRangePickerparsed: 0B(0.00%) gzip: 🔺+4B(+0.01%)
@mui/x-date-pickers-pro/DateRangePickerDayparsed: 0B(0.00%) gzip: 🔺+2B(+0.03%)
@mui/x-date-pickers-pro/DateRangePickerDay2parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/DateTimeRangePickerparsed: 0B(0.00%) gzip: 🔺+2B(0.00%)
@mui/x-date-pickers-pro/DesktopDateRangePickerparsed: 0B(0.00%) gzip: 🔺+5B(+0.01%)
@mui/x-date-pickers-pro/DesktopDateTimeRangePickerparsed: 0B(0.00%) gzip: 🔺+3B(+0.01%)
@mui/x-date-pickers-pro/DesktopTimeRangePickerparsed: 0B(0.00%) gzip: 🔺+3B(+0.01%)
@mui/x-date-pickers-pro/LocalizationProviderparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/MobileDateRangePickerparsed: 0B(0.00%) gzip: 🔺+3B(+0.01%)
@mui/x-date-pickers-pro/MobileDateTimeRangePickerparsed: 0B(0.00%) gzip: 🔺+3B(+0.01%)
@mui/x-date-pickers-pro/MobileTimeRangePickerparsed: 0B(0.00%) gzip: 🔺+2B(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: 🔺+2B(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 e43fbe0

Copy link

codspeed-hq bot commented Jul 10, 2025

CodSpeed Performance Report

Merging #18764 will improve performances by 8.56%

Comparing bernardobelchior:charts-hide-toolbar-by-default (e43fbe0) with master (3a86f28)

Summary

⚡ 1 improvements
✅ 9 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
ScatterChartPro with big data amount 446.4 ms 411.2 ms +8.56%

@bernardobelchior bernardobelchior force-pushed the charts-hide-toolbar-by-default branch from 42e3def to c54489f Compare July 10, 2025 14:27
{ "name": "DefaultizedLineSeriesType", "kind": "Interface" },
{ "name": "DefaultizedPieSeriesType", "kind": "Interface" },
{ "name": "DefaultizedPieValueType", "kind": "TypeAlias" },
{ "name": "DefaultizedRadarSeriesType", "kind": "Interface" },
{ "name": "DefaultizedScatterSeriesType", "kind": "Interface" },
{ "name": "DefaultizedSeriesType", "kind": "TypeAlias" },
{ "name": "defaultOnBeforeExport", "kind": "Function" },
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 was a bit unsure whether to export this or not 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Exporting it looks good. Should it be renamed onBerforeExportRemoveToolbar or something more explicit, I don't know

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 didn't want to name it after exactly what the function does because that might change in the future. For example, we might want it to hide more stuff (e.g., the zoom preview?).

But maybe we should call it onBeforeExportDefaultFn or something similar?


// Pro components
export * from './context';
export * from './hooks';
export * from './models';
Copy link
Member Author

Choose a reason for hiding this comment

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

We weren't exporting the heatmap types from the main index. We are now.

@bernardobelchior bernardobelchior marked this pull request as ready for review July 10, 2025 14:39
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 Jul 16, 2025
@bernardobelchior bernardobelchior force-pushed the charts-hide-toolbar-by-default branch from 1774c3d to 93e974a Compare July 16, 2025 14:43
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jul 16, 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.

Looks good. Should we also update the composition example in the next section to demonstrate how include a title and caption to show that it's feasible?

{ "name": "DefaultizedLineSeriesType", "kind": "Interface" },
{ "name": "DefaultizedPieSeriesType", "kind": "Interface" },
{ "name": "DefaultizedPieValueType", "kind": "TypeAlias" },
{ "name": "DefaultizedRadarSeriesType", "kind": "Interface" },
{ "name": "DefaultizedScatterSeriesType", "kind": "Interface" },
{ "name": "DefaultizedSeriesType", "kind": "TypeAlias" },
{ "name": "defaultOnBeforeExport", "kind": "Function" },
Copy link
Member

Choose a reason for hiding this comment

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

Exporting it looks good. Should it be renamed onBerforeExportRemoveToolbar or something more explicit, I don't know

@bernardobelchior
Copy link
Member Author

Looks good. Should we also update the composition example in the next section to demonstrate how include a title and caption to show that it's feasible?

I tried it and it isn't 100% feasible yet because the image export uses the chart's size to define the canvas size, causing the caption to be cut off.

I'll merge this PR and open another one where users will be able to customize the exported width, height and device pixel ratio.

@bernardobelchior bernardobelchior merged commit de2de2e into mui:master Jul 21, 2025
23 checks passed
@bernardobelchior bernardobelchior deleted the charts-hide-toolbar-by-default branch July 21, 2025 08:15
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: 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] Export button also prints the Toolbar
3 participants