Skip to content

Conversation

@alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Nov 26, 2025

Alternative to #20437

I made alexfauquette#14 to illustrate how it will simplify future feature

@mui-bot
Copy link

mui-bot commented Nov 26, 2025

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

Bundle size report

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 🔺+242B(+0.07%) 🔺+87B(+0.09%)
@mui/x-charts-pro 🔺+435B(+0.10%) 🔺+217B(+0.16%)
@mui/x-charts-premium 🔺+242B(+0.05%) 🔺+95B(+0.07%)
@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%)

Details of bundle changes

Generated by 🚫 dangerJS against 929faf2

@alexfauquette alexfauquette marked this pull request as ready for review November 26, 2025 13:53
@zannager zannager added the scope: charts Changes related to the charts. label Nov 26, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 26, 2025

CodSpeed Performance Report

Merging #20461 will not alter performance

Comparing alexfauquette:series-selectors (929faf2) with master (c70878f)1

Summary

✅ 13 untouched

Footnotes

  1. No successful run was found on master (3984429) during the generation of this report, so c70878f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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.

IMO, this approach looks cleaner, especially if we go with seriesLayout only containing the layout instead of the whole series.

One weird thing is that the layout won't be present for all series. I wonder if we should abstract getting an item's position somehow so that we can provide a getter and avoid calculating the whole layout for all charts. In a sankey chart, it would do the layout and find the item, returning its position, but in other charts it would call the axis scales to find its position.

...series,
series: {
[series.seriesOrder[0]]: {
...series.series[series.seriesOrder[0]],
Copy link
Member

Choose a reason for hiding this comment

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

We already have the series in the seriesProcessor. Would it make sense to seriesPositions to only return the positions?

Otherwise we're spreading the series again unnecessarily.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

I still return an object { sankeyLayout: (...) } instead of directly the layout.
My idea is to be able to add extra parameters latter if we need something

>;
};
series: DefaultizedPieSeriesType;
seriesComputedPosition: {};
Copy link
Member

Choose a reason for hiding this comment

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

I wonder we should call this seriesLayout to be shorter.

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 renamed most of those with "layout"

Copy link
Member

@JCQuintas JCQuintas left a comment

Choose a reason for hiding this comment

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

I was thinking of moving the layout logic to the sankey selectors, but @alexfauquette pointed out that for the tooltip position a generic selector with the position would be better instead.

@alexfauquette
Copy link
Member Author

One weird thing is that the layout won't be present for all series. I wonder if we should abstract getting an item's position somehow so that we can provide a getter and avoid calculating the whole layout for all charts.

That could effectively be interesting. It would create a big selector depending on

  • processed series
  • drawing area
  • cartesian axes
  • polar axes

It would basically replace hooks like the useBarPlotData()

I'm doing the modification to add layout for the sankey, such that we could latter add support for other series if needed

@alexfauquette alexfauquette added the type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. label Nov 27, 2025
Comment on lines +50 to +52
seriesLayout: {
sankeyLayout: SankeyLayout;
};
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 prefered this one instead of

seriesLayout: SankeyLayout;

yo ba able to add other layout if needed later

Copy link
Member

Choose a reason for hiding this comment

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

This is internal, so we could have gone for the simpler solution, I think, but this doesn't look bad either.

ids?: SeriesId | SeriesId[],
) => {
if (!ids || (Array.isArray(ids) && ids.length === 0)) {
if (ids === undefined || (Array.isArray(ids) && ids.length === 0)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Edge case to support the case of a series with id set to an empty string.

Signed-off-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
Comment on lines +50 to +52
seriesLayout: {
sankeyLayout: SankeyLayout;
};
Copy link
Member

Choose a reason for hiding this comment

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

This is internal, so we could have gone for the simpler solution, I think, but this doesn't look bad either.

Comment on lines 94 to 104
(Object.keys(processedSeries) as TSeriesType[]).forEach((type) => {
const processor = seriesConfig[type]?.seriesLayout;
if (processor !== undefined) {
const newValue = processor(processedSeries[type] as any, drawingArea);

if (newValue && newValue !== processedSeries[type]) {
processingDetected = true;
(seriesLayout as any)[type] = newValue;
}
}
});
Copy link
Member

Choose a reason for hiding this comment

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

From my tests, we can remove as any by doing this:

Suggested change
(Object.keys(processedSeries) as TSeriesType[]).forEach((type) => {
const processor = seriesConfig[type]?.seriesLayout;
if (processor !== undefined) {
const newValue = processor(processedSeries[type] as any, drawingArea);
if (newValue && newValue !== processedSeries[type]) {
processingDetected = true;
(seriesLayout as any)[type] = newValue;
}
}
});
(Object.keys(processedSeries) as TSeriesType[]).forEach((type) => {
const processor = seriesConfig[type]?.seriesLayout;
const thisSeries = processedSeries[type];
if (processor !== undefined && thisSeries !== undefined) {
const newValue = processor(thisSeries, drawingArea);
if (newValue && newValue !== processedSeries[type]) {
processingDetected = true;
seriesLayout[type] = newValue;
}
}
});

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, That let me totice some other as was useless

@alexfauquette alexfauquette merged commit 8acbe5b into mui:master Nov 28, 2025
22 checks passed
A-s-h-o-k pushed a commit to A-s-h-o-k/mui-x that referenced this pull request Dec 14, 2025
Signed-off-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
mapache-salvaje pushed a commit to mapache-salvaje/mui-x that referenced this pull request Dec 29, 2025
Signed-off-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
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.

5 participants