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] Improve sx documentation #12633

Closed
alexfauquette opened this issue Apr 2, 2024 · 4 comments
Closed

[charts] Improve sx documentation #12633

alexfauquette opened this issue Apr 2, 2024 · 4 comments
Assignees
Labels
component: charts This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation

Comments

@alexfauquette
Copy link
Member

alexfauquette commented Apr 2, 2024

Feedback received:
Chart components accept the sx props. From here, you can target any subcomponents with its class name.
how?

from https://mui.com/x/react-charts/styling/#

Search keywords:

@alexfauquette alexfauquette added docs Improvements or additions to the documentation component: charts This is the name of the generic UI component, not the React module! labels Apr 2, 2024
@derek-0000
Copy link
Contributor

derek-0000 commented Apr 12, 2024

Wondered If I can get this assigned? I started working on an example and wanted to know:

  • How many examples may it be enough to demonstrate the usage of sx for styling?

I kinda feel that one may be enough. But wanted to make sure.

Current wip:

image

import * as React from 'react';
import { BarChart } from '@mui/x-charts/BarChart';

export default function SxStylingTemplate() {
  return (
    <BarChart
      sx={{
        border: '1px solid rgba(255, 255, 255, 0.1)',
        backgroundImage:
          'linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px)',
        backgroundSize: '35px 35px',
        backgroundPosition: '20px 20px, 20px 20px',
        '& .MuiBarElement-root': {
          fill: '#000000',
          stroke: '#00DD43',
          strokeWidth: 2,
        },
        '& .MuiChartsAxis-root .MuiChartsAxis-line': {
          stroke: '#FFDD43',
        },
        '& .MuiChartsAxis-directionY > *:nth-child(2)': {
          stroke: 'red',
        },
        '& .MuiChartsAxis-directionY > *:nth-child(3)': {
          stroke: 'yellow',
        },
        '& .MuiChartsAxis-directionY > *:nth-child(4)': {
          stroke: 'yellow',
        },
        '& .MuiChartsAxis-directionY > *:nth-child(5)': {
          stroke: 'green',
        },
      }}
      xAxis={[{ scaleType: 'band', data: ['group A', 'group B', 'group C'] }]}
      series={[{ data: [4, 3, 5] }, { data: [1, 6, 3] }, { data: [2, 5, 6] }]}
      width={500}
      height={300}
    />
  );
}

@alexfauquette
Copy link
Member Author

Yes, one demo might be enough

If you want to do it, consider using the class objects to generate the selectors. For example [`.${axisClasses.left} .${axisClasses.label}`] like in this example: https://mui.com/x/react-charts/axis/#fixing-overflow-issues

I might rework some demo to use them instead of the hardcoded string such that ".MuiLineElement-root"

@derek-0000
Copy link
Contributor

Sure thing!

Copy link

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@alexfauquette: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

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! docs Improvements or additions to the documentation
Projects
None yet
Development

No branches or pull requests

2 participants