Skip to content

Conversation

alexfauquette
Copy link
Member

The line charts with a x-axis domainLimit: 'nice' is a bit weird because it ads extra with space on left/right if the first/last data point are not nice ones.

This PR moves the default of x-axis for line chart to 'strict'.

This can either looks like a breaking change

I would like to make it opt-in before v9, but not sure how to do it. I'm thinking about either

  • an env variable to set. But that could be tricky for users with different environments
  • creating a provider ChartsBreakingChange to put at the root of the project
  • using the theme provider and it's default props, with a props experimentalDefaultDomainLimit set at true for the ChartDataProvider

@alexfauquette alexfauquette added the breaking change Introduces changes that are not backward compatible. label Jun 23, 2025
@alexfauquette alexfauquette added the scope: charts Changes related to the charts. label Jun 23, 2025
@mui-bot
Copy link

mui-bot commented Jun 23, 2025

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

Updated pages:

Bundle size report

Total Size Change: 🔺+19.9KB(+0.15%) - Total Gzip Change: 🔺+6.02KB(+0.15%)
Files: 122 total (0 added, 0 removed, 40 changed)

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

@mui/x-chartsparsed: 🔺+798B(+0.26%) gzip: 🔺+256B(+0.28%)
@mui/x-charts-proparsed: 🔺+798B(+0.21%) gzip: 🔺+240B(+0.21%)
@mui/x-charts-pro/BarChartProparsed: 🔺+797B(+0.29%) gzip: 🔺+199B(+0.23%)
@mui/x-charts-pro/ChartContainerProparsed: 🔺+797B(+0.44%) gzip: 🔺+215B(+0.38%)
@mui/x-charts-pro/FunnelChartparsed: 🔺+797B(+0.32%) gzip: 🔺+202B(+0.27%)
@mui/x-charts-pro/LineChartProparsed: 🔺+797B(+0.28%) gzip: 🔺+228B(+0.26%)
@mui/x-charts-pro/PieChartProparsed: 🔺+797B(+0.34%) gzip: 🔺+214B(+0.29%)
@mui/x-charts-pro/ScatterChartProparsed: 🔺+797B(+0.29%) gzip: 🔺+217B(+0.25%)
@mui/x-charts/BarChartparsed: 🔺+797B(+0.38%) gzip: 🔺+248B(+0.38%)
@mui/x-charts/LineChartparsed: 🔺+797B(+0.35%) gzip: 🔺+252B(+0.36%)
@mui/x-charts/PieChartparsed: 🔺+797B(+0.40%) gzip: 🔺+231B(+0.38%)
@mui/x-charts/ScatterChartparsed: 🔺+797B(+0.40%) gzip: 🔺+244B(+0.40%)
@mui/x-charts/ChartContainerparsed: 🔺+796B(+0.53%) gzip: 🔺+246B(+0.53%)
@mui/x-charts-pro/ChartDataProviderProparsed: 🔺+729B(+0.42%) gzip: 🔺+225B(+0.41%)
@mui/x-charts-pro/Heatmapparsed: 🔺+729B(+0.32%) gzip: 🔺+217B(+0.30%)
@mui/x-charts-pro/RadarChartProparsed: 🔺+729B(+0.35%) gzip: 🔺+214B(+0.34%)
@mui/x-charts/RadarChartparsed: 🔺+728B(+0.38%) gzip: 🔺+222B(+0.37%)
@mui/x-charts/SparkLineChartparsed: 🔺+728B(+0.34%) gzip: 🔺+184B(+0.28%)
@mui/x-charts/ChartDataProviderparsed: 🔺+727B(+0.50%) gzip: 🔺+224B(+0.50%)
@mui/x-charts/Gaugeparsed: 🔺+666B(+0.46%) gzip: 🔺+172B(+0.38%)
@mui/x-charts-pro/ChartsToolbarProparsed: 🔺+414B(+0.63%) gzip: 🔺+148B(+0.63%)
@mui/x-charts/ChartsAxisparsed: 🔺+414B(+0.58%) gzip: 🔺+139B(+0.55%)
@mui/x-charts/ChartsXAxisparsed: 🔺+414B(+0.61%) gzip: 🔺+144B(+0.59%)
@mui/x-charts-pro/ChartZoomSliderparsed: 🔺+413B(+0.39%) gzip: 🔺+139B(+0.39%)
@mui/x-charts/ChartsAxisHighlightparsed: 🔺+413B(+0.67%) gzip: 🔺+141B(+0.65%)
@mui/x-charts/ChartsGridparsed: 🔺+413B(+0.70%) gzip: 🔺+138B(+0.65%)
@mui/x-charts/ChartsLegendparsed: 🔺+413B(+0.57%) gzip: 🔺+143B(+0.56%)
@mui/x-charts/ChartsReferenceLineparsed: 🔺+413B(+0.68%) gzip: 🔺+144B(+0.66%)
@mui/x-charts/ChartsSurfaceparsed: 🔺+413B(+0.69%) gzip: 🔺+143B(+0.67%)
@mui/x-charts/ChartsTooltipparsed: 🔺+413B(+0.54%) gzip: 🔺+136B(+0.52%)
@mui/x-charts/ChartsYAxisparsed: 🔺+413B(+0.62%) gzip: 🔺+138B(+0.57%)
@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-data-gridparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-data-grid-premiumparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-data-grid-premium/DataGridPremiumparsed: 0B(0.00%) gzip: 🔺+1B(0.00%)
@mui/x-data-grid-proparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-data-grid-pro/DataGridProparsed: 0B(0.00%) gzip: 0B(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: 🔺+2B(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: 🔺+2B(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: 🔺+1B(0.00%)
@mui/x-date-pickers-pro/DesktopDateRangePickerparsed: 0B(0.00%) gzip: 🔺+1B(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: 🔺+1B(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: 🔺+1B(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 fcd8f77

@JCQuintas
Copy link
Member

  • an env variable to set. But that could be tricky for users with different environments
  • creating a provider ChartsBreakingChange to put at the root of the project
  • using the theme provider and it's default props, with a props experimentalDefaultDomainLimit set at true for the ChartDataProvider

Why can't we keep it off and the user can set strict if they need? (current behaviour)

We can then just flip it next release

@JCQuintas
Copy link
Member

Or is this a proposal for all future breaking changes? 🤔

@alexfauquette
Copy link
Member Author

Or is this a proposal for all future breaking changes? 🤔

Yes, my opinion is that a next major in march is too far for those modification. In the data grid we had a prop experimentalFeature={{ featureToEnable: true }} which opt-in the modification.

But for chart we should move that at a hight level.

Why can't we keep it off and the user can set strict if they need? (current behaviour)

We can, but I'm not in love with the idea of adding this strict to all the x-axis on lin chart demos. XHihc is necessary because some of them looks weird on mobile phone (due to the impact of a small with for the same number of ticks)

@JCQuintas
Copy link
Member

Got it, in that case either a plugin/ChartsDataProvider approach or a overarching context can work for us.

@bernardobelchior
Copy link
Member

In the data grid we had a prop experimentalFeature={{ featureToEnable: true }} which opt-in the modification.

Can't we follow the same approach? All charts and the ChartDataProvider would need to accept this prop.

Copy link

codspeed-hq bot commented Jun 25, 2025

CodSpeed Performance Report

Merging #18506 will not alter performance

Comparing alexfauquette:docs-mobile (fcd8f77) with master (c4cad52)

Summary

✅ 10 untouched benchmarks

@@ -162,6 +163,16 @@ function loadDependencies() {
);
}

const experimentaChartFeatures = createTheme({
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
const experimentaChartFeatures = createTheme({
const experimentalChartFeatures = createTheme({

@@ -331,7 +342,7 @@ function AppWrapper(props) {
<PageContext.Provider value={pageContextValue}>
<ThemeWrapper>
<DocsStyledEngineProvider cacheLtr={emotionCache}>
{children}
<ThemeProvider theme={experimentaChartFeatures}>{children}</ThemeProvider>
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if this will reduce the reproducibility of our docs.

When someone creates a sandbox from our docs, these experimental features won't be enabled, will they? So the sandboxes will look different from the docs.

Furthermore, users copying code from our docs will see different results in their environment because they don't know they need to enable this experimental feature.

I know it's verbose, but maybe we should use the strict domain limit in our demos and flip the default in v9?

We could also keep these experimental chart features to ease migration, but I'm not sure we should enable them in our docs.

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 will do the copy paste to most of our line demos in a dedicated PR to avoid adding more diff in this one

Comment on lines 2 to 3
{ date: new Date(1990, 0, 1), fr: 28129, gb: 26189, dl: 25391 },
{ date: new Date(1991, 0, 1), fr: 28294.264, gb: 25792.014, dl: 26769.96 },
Copy link
Member

Choose a reason for hiding this comment

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

Why remove these data points?

Copy link
Member Author

Choose a reason for hiding this comment

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

To make the demo more explicit. 1990 is already a rounded number.

I also considered removing it only for the domain limit demo. But demo could also start in 1992

Copy link
Member

Choose a reason for hiding this comment

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

I also considered removing it only for the domain limit demo

Yeah, I think that makes more sense


export interface ChartExperimentalFeatures {
/**
* Default domainLimit to strict for line chart x-axis.
Copy link
Member

Choose a reason for hiding this comment

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

I find it a bit weird that we can enable this for a ScatterChart, for example, even though it might not have any effect.

It's probably fine, though

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah the root cause is the fact it in a common experimentalFeature object. We could remove it from all other charts for now.

And find a better naming than strictDomainLimit tho highlight the facts it's related to line plotting

Copy link
Member

@bernardobelchior bernardobelchior Jul 7, 2025

Choose a reason for hiding this comment

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

preferStrictDomainInLineCharts?

Copy link
Member Author

Choose a reason for hiding this comment

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

A bit long but sounds better 👍

@@ -55,6 +56,7 @@ type ComputeCommonParams<T extends ChartSeriesType = ChartSeriesType> = {
zoomMap?: Map<AxisId, ZoomData>;
zoomOptions?: Record<AxisId, DefaultizedZoomOptions>;
getFilters?: GetZoomAxisFilters;
experimental_strictDomainLimit?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

computeAxisValue doesn't need to know that this is an experimental flag.

We can just call it something like this:

Suggested change
experimental_strictDomainLimit?: boolean;
defaultLineSeriesToStrictDomain?: boolean;

or

Suggested change
experimental_strictDomainLimit?: boolean;
preferStrictDomainLimit?: boolean;

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 went with experimental because it will be useless in next major. So it's a way to tell "Hey you can remove this param"

Copy link
Member

Choose a reason for hiding this comment

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

We can add a comment for that, but not that big of an issue

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

github-actions bot commented Jul 9, 2025

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 Jul 9, 2025
import { dataset } from './GDPperCapita';

export default function LineDefaultDomainLimit() {
const [preferStrictDomainInLineCharts, setpreferStrictDomainInLineCharts] =
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
const [preferStrictDomainInLineCharts, setpreferStrictDomainInLineCharts] =
const [preferStrictDomainInLineCharts, setPreferStrictDomainInLineCharts] =

Copy link
Member

@bernardobelchior bernardobelchior left a comment

Choose a reason for hiding this comment

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

Nice!

@alexfauquette alexfauquette merged commit 5e59db3 into mui:master Jul 10, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Introduces changes that are not backward compatible. scope: charts Changes related to the charts.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants