Skip to content

[charts] Remove default generic of item identifiers#21182

Open
alexfauquette wants to merge 9 commits intomui:masterfrom
alexfauquette:remove-global-identifier
Open

[charts] Remove default generic of item identifiers#21182
alexfauquette wants to merge 9 commits intomui:masterfrom
alexfauquette:remove-global-identifier

Conversation

@alexfauquette
Copy link
Member

Extracted from #21161

The idea is that item identifier does not make that much sense. For now most of the identifier are the same { type, seriesId, dataIndex } but with heatmap will be { type, seriesId, xIndex, yIndex } or the sankey identifier

Not sure about how to document that "breaking change" or document it

@alexfauquette alexfauquette added the breaking change Introduces changes that are not backward compatible. label Jan 30, 2026
@alexfauquette alexfauquette added typescript 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 Jan 30, 2026
@mui-bot
Copy link

mui-bot commented Jan 30, 2026

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

Updated pages:

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 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@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 664f3ca

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 30, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing alexfauquette:remove-global-identifier (664f3ca) with master (adbcb8b)1

Summary

✅ 14 untouched benchmarks

Footnotes

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

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.

Not sure this is necessary. Can't we have the initial value be "anytype", and users trim it down by either SeriesItemIdentifier<'line'> or

const item = ourOutputItem

if (item.type !== 'heatmap') {
 // ignore
}
// do something

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

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

@alexfauquette
Copy link
Member Author

Not sure this is necessary. Can't we have the initial value be "anytype", and users trim it down by either SeriesItemIdentifier<'line'> or

That's kind of already the case

For callback

If you look at the definition of the ChartDataProviderProProps, the TSeries is by default set to ChartSeriesType so the plugins and all their parameters will be set the same way.

So if the onItemClick depend on the series it will by types as an union of any series type

export type ChartDataProviderProProps<
  TSeries extends ChartSeriesType = ChartSeriesType,
  TSignatures extends readonly ChartAnyPluginSignature[] = AllPluginSignatures<TSeries>,
> = ChartDataProviderProps<TSeries, TSignatures> &
  ChartProviderProps<TSeries, TSignatures>['pluginParams'] & {
    /**
     * Slots to customize charts' components.
     */
    slots?: Partial<ChartDataProviderProSlots>;
    /**
     * The props for the slots.
     */
    slotProps?: Partial<ChartDataProviderProSlotProps>;
  };

For user state

Here it changes a bit, because it forces the user to specify which series type they plan to store.
IMO it's not a big deal

Why doing it

I got multiple TS issue that were hard to understand because sometime the generic argument is provided, sometime not, so it defaultize to all series type. Leading to error like "The union does not match with this other union"

Removing the default value forces us to correctly type pass the generic or explicitly say "this can be any series type"

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 2, 2026
@JCQuintas
Copy link
Member

The benefits seem to outweigh the drawbacks, so we can roll with it :)

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. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants