-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[charts] Add ChartsGrid
to themeAugmentation
#13026
Conversation
Deploy preview: https://deploy-preview-13026--material-ui-x.netlify.app/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the testing, it seems that it was missing from themeAugmentation
by design. 🙈
Certain changes in one or another way have to be made. 🤷 🤔
@@ -18,6 +18,10 @@ export interface ChartsComponents { | |||
MuiChartsClipPath?: { | |||
defaultProps?: ComponentsProps['MuiChartsClipPath']; | |||
}; | |||
MuiChartsGrid?: { | |||
defaultProps?: ComponentsProps['MuiChartsGrid']; | |||
styleOverrides?: ComponentsOverrides['MuiChartsGrid']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only the root
slot/class seems to work, because only that one is present on the overridesResolver
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, the verticalLine
and horizontalLine
slots will still not do anything. 🙈
Consider applying the following diff to make them work:
diff --git a/packages/x-charts/src/ChartsGrid/ChartsGrid.tsx b/packages/x-charts/src/ChartsGrid/ChartsGrid.tsx
index f2d74db40..452083540 100644
--- a/packages/x-charts/src/ChartsGrid/ChartsGrid.tsx
+++ b/packages/x-charts/src/ChartsGrid/ChartsGrid.tsx
@@ -5,7 +5,11 @@ import { styled, useThemeProps } from '@mui/material/styles';
import { CartesianContext } from '../context/CartesianContextProvider';
import { useTicks } from '../hooks/useTicks';
-import { ChartsGridClasses, getChartsGridUtilityClass } from './chartsGridClasses';
+import {
+ ChartsGridClasses,
+ chartsGridClasses,
+ getChartsGridUtilityClass,
+} from './chartsGridClasses';
const GridRoot = styled('g', {
name: 'MuiChartsGrid',
@@ -16,7 +20,11 @@ const GridRoot = styled('g', {
const GridLine = styled('line', {
name: 'MuiChartsGrid',
slot: 'Line',
- overridesResolver: (props, styles) => styles.line,
+ overridesResolver: (props, styles) => [
+ { [`&.${chartsGridClasses.verticalLine}`]: styles.verticalLine },
+ { [`&.${chartsGridClasses.horizontalLine}`]: styles.horizontalLine },
+ styles.line,
+ ],
})(({ theme }) => ({
stroke: (theme.vars || theme).palette.divider,
shapeRendering: 'crispEdges',
An example for reference:
mui-x/packages/x-date-pickers/src/DateTimePicker/DateTimePickerToolbar.tsx
Lines 215 to 218 in a3add0b
overridesResolver: (props, styles) => [ | |
{ [`.${dateTimePickerToolbarClasses.ampmLabel}`]: styles.ampmLabel }, | |
{ [`&.${dateTimePickerToolbarClasses.ampmLandscape}`]: styles.ampmLandscape }, | |
styles.ampmSelection, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and very welcome improvement! 💯 🚀 💙
@@ -18,6 +18,10 @@ export interface ChartsComponents { | |||
MuiChartsClipPath?: { | |||
defaultProps?: ComponentsProps['MuiChartsClipPath']; | |||
}; | |||
MuiChartsGrid?: { | |||
defaultProps?: ComponentsProps['MuiChartsGrid']; | |||
styleOverrides?: ComponentsOverrides['MuiChartsGrid']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, the verticalLine
and horizontalLine
slots will still not do anything. 🙈
Consider applying the following diff to make them work:
diff --git a/packages/x-charts/src/ChartsGrid/ChartsGrid.tsx b/packages/x-charts/src/ChartsGrid/ChartsGrid.tsx
index f2d74db40..452083540 100644
--- a/packages/x-charts/src/ChartsGrid/ChartsGrid.tsx
+++ b/packages/x-charts/src/ChartsGrid/ChartsGrid.tsx
@@ -5,7 +5,11 @@ import { styled, useThemeProps } from '@mui/material/styles';
import { CartesianContext } from '../context/CartesianContextProvider';
import { useTicks } from '../hooks/useTicks';
-import { ChartsGridClasses, getChartsGridUtilityClass } from './chartsGridClasses';
+import {
+ ChartsGridClasses,
+ chartsGridClasses,
+ getChartsGridUtilityClass,
+} from './chartsGridClasses';
const GridRoot = styled('g', {
name: 'MuiChartsGrid',
@@ -16,7 +20,11 @@ const GridRoot = styled('g', {
const GridLine = styled('line', {
name: 'MuiChartsGrid',
slot: 'Line',
- overridesResolver: (props, styles) => styles.line,
+ overridesResolver: (props, styles) => [
+ { [`&.${chartsGridClasses.verticalLine}`]: styles.verticalLine },
+ { [`&.${chartsGridClasses.horizontalLine}`]: styles.horizontalLine },
+ styles.line,
+ ],
})(({ theme }) => ({
stroke: (theme.vars || theme).palette.divider,
shapeRendering: 'crispEdges',
An example for reference:
mui-x/packages/x-date-pickers/src/DateTimePicker/DateTimePickerToolbar.tsx
Lines 215 to 218 in a3add0b
overridesResolver: (props, styles) => [ | |
{ [`.${dateTimePickerToolbarClasses.ampmLabel}`]: styles.ampmLabel }, | |
{ [`&.${dateTimePickerToolbarClasses.ampmLandscape}`]: styles.ampmLandscape }, | |
styles.ampmSelection, |
Not sure if it's intentional or not, but came across this issue here.