Skip to content

[charts] Support unknownColor in color scale#22813

Merged
alexfauquette merged 11 commits into
mui:masterfrom
alexfauquette:fixi-map-color
Jun 18, 2026
Merged

[charts] Support unknownColor in color scale#22813
alexfauquette merged 11 commits into
mui:masterfrom
alexfauquette:fixi-map-color

Conversation

@alexfauquette

Copy link
Copy Markdown
Member

This add support for unknownColor in continuouse scales.

For all charts the behavior shoul dnot be impacted. If unownColor is not provided the scale will return null and so we still fall back to the series color.

For the mapShapes, the behavior differs. The getColor returns null and the ShapePlot does not render the shape

@alexfauquette
alexfauquette requested a review from JCQuintas as a code owner June 15, 2026 13:25
@alexfauquette alexfauquette 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 Jun 15, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Jun 15, 2026

Copy link
Copy Markdown

Deploy preview

Bundle size

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 ▼-40B(-0.01%) ▼-9B(-0.01%)
@mui/x-charts-pro ▼-40B(-0.01%) ▼-7B(0.00%)
@mui/x-charts-premium ▼-131B(-0.02%) 🔺+1B(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%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

Comment on lines +114 to +115
By default shapes with unknown values are ignored.
Specify the `unknownColor` property in the `colorMap` to render them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This behaviour is specific of the map right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, I added test to be sure I do not mess up with other charts

For other charts the beahvior is

  • if unknownColor is defined, use it
  • if it's not defined, use the series color

Comment on lines +60 to +66
<FormControlLabel
checked={unknownColor}
control={
<Checkbox onChange={(event) => setUnknownColor(event.target.checked)} />
}
label="Use unknown color"
labelPlacement="end"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it be better for this demo to not have the background? 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will add an info box to inform user about the impact bout the tooltip and add an option in the demos actions to play with it

@alexfauquette
alexfauquette merged commit ad6ec2f into mui:master Jun 18, 2026
20 of 21 checks passed
mbrookes pushed a commit to mbrookes/mui-x that referenced this pull request Jun 27, 2026
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.

2 participants