Skip to content
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

Merged
merged 3 commits into from
May 6, 2024

Conversation

noraleonte
Copy link
Contributor

Not sure if it's intentional or not, but came across this issue here.

@noraleonte noraleonte added typescript enhancement This is not a bug, nor a new feature component: charts This is the name of the generic UI component, not the React module! labels May 6, 2024
@noraleonte noraleonte self-assigned this May 6, 2024
@mui-bot
Copy link

mui-bot commented May 6, 2024

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

Generated by 🚫 dangerJS against 317781f

Copy link
Member

@LukasTy LukasTy left a 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'];
Copy link
Member

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.

Copy link
Member

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:

overridesResolver: (props, styles) => [
{ [`.${dateTimePickerToolbarClasses.ampmLabel}`]: styles.ampmLabel },
{ [`&.${dateTimePickerToolbarClasses.ampmLandscape}`]: styles.ampmLandscape },
styles.ampmSelection,

Copy link
Member

@LukasTy LukasTy left a 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'];
Copy link
Member

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:

overridesResolver: (props, styles) => [
{ [`.${dateTimePickerToolbarClasses.ampmLabel}`]: styles.ampmLabel },
{ [`&.${dateTimePickerToolbarClasses.ampmLandscape}`]: styles.ampmLandscape },
styles.ampmSelection,

@noraleonte noraleonte merged commit 05c2c21 into mui:master May 6, 2024
15 checks passed
@noraleonte noraleonte deleted the add-charts-grid-to-theme branch May 6, 2024 17:07
joakimtveter pushed a commit to joakimtveter/mui-x that referenced this pull request Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: charts This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants