Skip to content

Commit

Permalink
[docs] Use charts classes objects (#12781)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Apr 15, 2024
1 parent 93e7245 commit b540a36
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 33 deletions.
6 changes: 3 additions & 3 deletions docs/data/charts/areas-demo/AreaChartFillByValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import { green, red } from '@mui/material/colors';
import Stack from '@mui/material/Stack';
import { useYScale, useDrawingArea } from '@mui/x-charts/hooks';
import { LineChart } from '@mui/x-charts/LineChart';
import { LineChart, areaElementClasses } from '@mui/x-charts/LineChart';

const data = [4000, 3000, -1000, 500, -2100, -250, 3490];
const xData = ['Page A', 'Page B', 'Page C', 'Page D', 'Page E', 'Page F', 'Page G'];
Expand Down Expand Up @@ -43,7 +43,7 @@ export default function AreaChartFillByValue() {
height={200}
margin={{ top: 20, bottom: 30, left: 75 }}
sx={{
'& .MuiAreaElement-root': {
[`& .${areaElementClasses.root}`]: {
fill: 'url(#swich-color-id-1)',
},
}}
Expand All @@ -64,7 +64,7 @@ export default function AreaChartFillByValue() {
height={200}
margin={{ top: 20, bottom: 30, left: 75 }}
sx={{
'& .MuiAreaElement-root': {
[`& .${areaElementClasses.root}`]: {
fill: 'url(#swich-color-id-2)',
},
}}
Expand Down
6 changes: 3 additions & 3 deletions docs/data/charts/areas-demo/AreaChartFillByValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ScaleLinear } from 'd3-scale';
import { green, red } from '@mui/material/colors';
import Stack from '@mui/material/Stack';
import { useYScale, useDrawingArea } from '@mui/x-charts/hooks';
import { LineChart } from '@mui/x-charts/LineChart';
import { LineChart, areaElementClasses } from '@mui/x-charts/LineChart';

const data = [4000, 3000, -1000, 500, -2100, -250, 3490];
const xData = ['Page A', 'Page B', 'Page C', 'Page D', 'Page E', 'Page F', 'Page G'];
Expand Down Expand Up @@ -50,7 +50,7 @@ export default function AreaChartFillByValue() {
height={200}
margin={{ top: 20, bottom: 30, left: 75 }}
sx={{
'& .MuiAreaElement-root': {
[`& .${areaElementClasses.root}`]: {
fill: 'url(#swich-color-id-1)',
},
}}
Expand All @@ -71,7 +71,7 @@ export default function AreaChartFillByValue() {
height={200}
margin={{ top: 20, bottom: 30, left: 75 }}
sx={{
'& .MuiAreaElement-root': {
[`& .${areaElementClasses.root}`]: {
fill: 'url(#swich-color-id-2)',
},
}}
Expand Down
4 changes: 2 additions & 2 deletions docs/data/charts/areas-demo/SimpleAreaChart.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { LineChart } from '@mui/x-charts/LineChart';
import { LineChart, lineElementClasses } from '@mui/x-charts/LineChart';

const uData = [4000, 3000, 2000, 2780, 1890, 2390, 3490];
const xLabels = [
Expand All @@ -20,7 +20,7 @@ export default function SimpleAreaChart() {
series={[{ data: uData, label: 'uv', area: true, showMark: false }]}
xAxis={[{ scaleType: 'point', data: xLabels }]}
sx={{
'.MuiLineElement-root': {
[`& .${lineElementClasses.root}`]: {
display: 'none',
},
}}
Expand Down
4 changes: 2 additions & 2 deletions docs/data/charts/areas-demo/SimpleAreaChart.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { LineChart } from '@mui/x-charts/LineChart';
import { LineChart, lineElementClasses } from '@mui/x-charts/LineChart';

const uData = [4000, 3000, 2000, 2780, 1890, 2390, 3490];
const xLabels = [
Expand All @@ -20,7 +20,7 @@ export default function SimpleAreaChart() {
series={[{ data: uData, label: 'uv', area: true, showMark: false }]}
xAxis={[{ scaleType: 'point', data: xLabels }]}
sx={{
'.MuiLineElement-root': {
[`& .${lineElementClasses.root}`]: {
display: 'none',
},
}}
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/areas-demo/SimpleAreaChart.tsx.preview
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
series={[{ data: uData, label: 'uv', area: true, showMark: false }]}
xAxis={[{ scaleType: 'point', data: xLabels }]}
sx={{
'.MuiLineElement-root': {
[`& .${lineElementClasses.root}`]: {
display: 'none',
},
}}
Expand Down
4 changes: 2 additions & 2 deletions docs/data/charts/areas-demo/StackedAreaChart.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { LineChart } from '@mui/x-charts/LineChart';
import { LineChart, lineElementClasses } from '@mui/x-charts/LineChart';

const uData = [4000, 3000, 2000, 2780, 1890, 2390, 3490];
const pData = [2400, 1398, 9800, 3908, 4800, 3800, 4300];
Expand Down Expand Up @@ -32,7 +32,7 @@ export default function StackedAreaChart() {
]}
xAxis={[{ scaleType: 'point', data: xLabels }]}
sx={{
'.MuiLineElement-root': {
[`& .${lineElementClasses.root}`]: {
display: 'none',
},
}}
Expand Down
4 changes: 2 additions & 2 deletions docs/data/charts/areas-demo/StackedAreaChart.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { LineChart } from '@mui/x-charts/LineChart';
import { LineChart, lineElementClasses } from '@mui/x-charts/LineChart';

const uData = [4000, 3000, 2000, 2780, 1890, 2390, 3490];
const pData = [2400, 1398, 9800, 3908, 4800, 3800, 4300];
Expand Down Expand Up @@ -32,7 +32,7 @@ export default function StackedAreaChart() {
]}
xAxis={[{ scaleType: 'point', data: xLabels }]}
sx={{
'.MuiLineElement-root': {
[`& .${lineElementClasses.root}`]: {
display: 'none',
},
}}
Expand Down
12 changes: 8 additions & 4 deletions docs/data/charts/line-demo/DashedLineChart.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as React from 'react';
import { LineChart } from '@mui/x-charts/LineChart';
import {
LineChart,
lineElementClasses,
markElementClasses,
} from '@mui/x-charts/LineChart';

const uData = [4000, 3000, 2000, 2780, 1890, 2390, 3490];
const pData = [2400, 1398, 9800, 3908, 4800, 3800, 4300];
Expand All @@ -24,7 +28,7 @@ export default function DashedLineChart() {
]}
xAxis={[{ scaleType: 'point', data: xLabels }]}
sx={{
'.MuiLineElement-root, .MuiMarkElement-root': {
[`.${lineElementClasses.root}, .${markElementClasses.root}`]: {
strokeWidth: 1,
},
'.MuiLineElement-series-pvId': {
Expand All @@ -33,10 +37,10 @@ export default function DashedLineChart() {
'.MuiLineElement-series-uvId': {
strokeDasharray: '3 4 5 2',
},
'.MuiMarkElement-root:not(.MuiMarkElement-highlighted)': {
[`.${markElementClasses.root}:not(.${markElementClasses.highlighted})`]: {
fill: '#fff',
},
'& .MuiMarkElement-highlighted': {
[`& .${markElementClasses.highlighted}`]: {
stroke: 'none',
},
}}
Expand Down
12 changes: 8 additions & 4 deletions docs/data/charts/line-demo/DashedLineChart.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as React from 'react';
import { LineChart } from '@mui/x-charts/LineChart';
import {
LineChart,
lineElementClasses,
markElementClasses,
} from '@mui/x-charts/LineChart';

const uData = [4000, 3000, 2000, 2780, 1890, 2390, 3490];
const pData = [2400, 1398, 9800, 3908, 4800, 3800, 4300];
Expand All @@ -24,7 +28,7 @@ export default function DashedLineChart() {
]}
xAxis={[{ scaleType: 'point', data: xLabels }]}
sx={{
'.MuiLineElement-root, .MuiMarkElement-root': {
[`.${lineElementClasses.root}, .${markElementClasses.root}`]: {
strokeWidth: 1,
},
'.MuiLineElement-series-pvId': {
Expand All @@ -33,10 +37,10 @@ export default function DashedLineChart() {
'.MuiLineElement-series-uvId': {
strokeDasharray: '3 4 5 2',
},
'.MuiMarkElement-root:not(.MuiMarkElement-highlighted)': {
[`.${markElementClasses.root}:not(.${markElementClasses.highlighted})`]: {
fill: '#fff',
},
'& .MuiMarkElement-highlighted': {
[`& .${markElementClasses.highlighted}`]: {
stroke: 'none',
},
}}
Expand Down
11 changes: 8 additions & 3 deletions docs/data/charts/line-demo/TinyLineChart.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as React from 'react';
import { ChartContainer } from '@mui/x-charts';
import { LinePlot, MarkPlot } from '@mui/x-charts/LineChart';
import {
LinePlot,
MarkPlot,
lineElementClasses,
markElementClasses,
} from '@mui/x-charts/LineChart';

const pData = [2400, 1398, 9800, 3908, 4800, 3800, 4300];
const xLabels = [
Expand All @@ -21,11 +26,11 @@ export default function TinyLineChart() {
series={[{ type: 'line', data: pData }]}
xAxis={[{ scaleType: 'point', data: xLabels }]}
sx={{
'.MuiLineElement-root': {
[`& .${lineElementClasses.root}`]: {
stroke: '#8884d8',
strokeWidth: 2,
},
'.MuiMarkElement-root': {
[`& .${markElementClasses.root}`]: {
stroke: '#8884d8',
scale: '0.6',
fill: '#fff',
Expand Down
11 changes: 8 additions & 3 deletions docs/data/charts/line-demo/TinyLineChart.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as React from 'react';
import { ChartContainer } from '@mui/x-charts';
import { LinePlot, MarkPlot } from '@mui/x-charts/LineChart';
import {
LinePlot,
MarkPlot,
lineElementClasses,
markElementClasses,
} from '@mui/x-charts/LineChart';

const pData = [2400, 1398, 9800, 3908, 4800, 3800, 4300];
const xLabels = [
Expand All @@ -21,11 +26,11 @@ export default function TinyLineChart() {
series={[{ type: 'line', data: pData }]}
xAxis={[{ scaleType: 'point', data: xLabels }]}
sx={{
'.MuiLineElement-root': {
[`& .${lineElementClasses.root}`]: {
stroke: '#8884d8',
strokeWidth: 2,
},
'.MuiMarkElement-root': {
[`& .${markElementClasses.root}`]: {
stroke: '#8884d8',
scale: '0.6',
fill: '#fff',
Expand Down
4 changes: 2 additions & 2 deletions docs/data/charts/lines/CSSCustomization.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { LineChart } from '@mui/x-charts/LineChart';
import { LineChart, lineElementClasses } from '@mui/x-charts/LineChart';

const years = [
new Date(1990, 0, 1),
Expand Down Expand Up @@ -58,7 +58,7 @@ export default function CSSCustomization() {
return (
<LineChart
sx={{
'& .MuiLineElement-root': {
[`& .${lineElementClasses.root}`]: {
strokeDasharray: '10 5',
strokeWidth: 4,
},
Expand Down
4 changes: 2 additions & 2 deletions docs/data/charts/lines/CSSCustomization.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { LineChart } from '@mui/x-charts/LineChart';
import { LineChart, lineElementClasses } from '@mui/x-charts/LineChart';

const years = [
new Date(1990, 0, 1),
Expand Down Expand Up @@ -58,7 +58,7 @@ export default function CSSCustomization() {
return (
<LineChart
sx={{
'& .MuiLineElement-root': {
[`& .${lineElementClasses.root}`]: {
strokeDasharray: '10 5',
strokeWidth: 4,
},
Expand Down

0 comments on commit b540a36

Please sign in to comment.