Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardobelchior committed Feb 5, 2025
1 parent 2d918a0 commit ecdb48c
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/data/charts/sparkline/ColorCustomization.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react';
import Stack from '@mui/material/Stack';
import { SparkLineChart } from '@mui/x-charts/SparkLineChart';

const settings = {
height: 100,
yAxis: { min: 0, max: 100 },
};

const values = [0, 2, 3, 4, 6, 8, 7, 9, 15, 6, 8, 7, 12];

export default function ColorCustomization() {
return (
<Stack sx={{ width: '100%' }}>
<SparkLineChart data={values} color="green" {...settings} />
</Stack>
);
}
18 changes: 18 additions & 0 deletions docs/data/charts/sparkline/ColorCustomization.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react';
import Stack from '@mui/material/Stack';
import { SparkLineChart } from '@mui/x-charts/SparkLineChart';

const settings = {
height: 100,
yAxis: { min: 0, max: 100 },
} as const;

const values = [0, 2, 3, 4, 6, 8, 7, 9, 15, 6, 8, 7, 12];

export default function ColorCustomization() {
return (
<Stack sx={{ width: '100%' }}>
<SparkLineChart data={values} color="green" {...settings} />
</Stack>
);
}
1 change: 1 addition & 0 deletions docs/data/charts/sparkline/ColorCustomization.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<SparkLineChart data={values} color="green" {...settings} />
22 changes: 22 additions & 0 deletions docs/data/charts/sparkline/ColorCustomizationMode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react';
import Stack from '@mui/material/Stack';
import { SparkLineChart } from '@mui/x-charts/SparkLineChart';

const settings = {
height: 100,
yAxis: { min: 0, max: 100 },
};

const values = [0, 2, 3, 4, 6, 8, 7, 9, 15, 6, 8, 7, 12];

export default function ColorCustomizationMode() {
return (
<Stack sx={{ width: '100%' }}>
<SparkLineChart
data={values}
color={(mode) => (mode === 'light' ? 'black' : 'white')}
{...settings}
/>
</Stack>
);
}
22 changes: 22 additions & 0 deletions docs/data/charts/sparkline/ColorCustomizationMode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react';
import Stack from '@mui/material/Stack';
import { SparkLineChart } from '@mui/x-charts/SparkLineChart';

const settings = {
height: 100,
yAxis: { min: 0, max: 100 },
} as const;

const values = [0, 2, 3, 4, 6, 8, 7, 9, 15, 6, 8, 7, 12];

export default function ColorCustomizationMode() {
return (
<Stack sx={{ width: '100%' }}>
<SparkLineChart
data={values}
color={(mode) => (mode === 'light' ? 'black' : 'white')}
{...settings}
/>
</Stack>
);
}
5 changes: 5 additions & 0 deletions docs/data/charts/sparkline/ColorCustomizationMode.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<SparkLineChart
data={values}
color={(mode) => (mode === 'light' ? 'black' : 'white')}
{...settings}
/>
12 changes: 12 additions & 0 deletions docs/data/charts/sparkline/sparkline.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,15 @@ The demo below shows different ways to set the y-axis range.
They always display the same data, going from -15 to 92, but with different `domainLimit` settings.

{{"demo": "CustomDomainYAxis.js"}}

## Color Customization

You can customize the color of the sparkline by providing a color to the `color` prop.

{{"demo": "ColorCustomization.js"}}

The `color` prop also accepts a function that will be called with the mode (light or dark), so you can adapt the color to user preferences.

Check warning on line 76 in docs/data/charts/sparkline/sparkline.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.Will] Avoid using 'will'. Raw Output: {"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "docs/data/charts/sparkline/sparkline.md", "range": {"start": {"line": 76, "column": 47}}}, "severity": "WARNING"}

Check warning on line 76 in docs/data/charts/sparkline/sparkline.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.Will] Avoid using 'will'. Raw Output: {"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "docs/data/charts/sparkline/sparkline.md", "range": {"start": {"line": 76, "column": 47}}}, "severity": "WARNING"}

The following example will show a white line if this page is in dark mode, or a black one if it is in light mode.

Check warning on line 78 in docs/data/charts/sparkline/sparkline.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.Will] Avoid using 'will'. Raw Output: {"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "docs/data/charts/sparkline/sparkline.md", "range": {"start": {"line": 78, "column": 23}}}, "severity": "WARNING"}

Check warning on line 78 in docs/data/charts/sparkline/sparkline.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.Will] Avoid using 'will'. Raw Output: {"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "docs/data/charts/sparkline/sparkline.md", "range": {"start": {"line": 78, "column": 23}}}, "severity": "WARNING"}

{{"demo": "ColorCustomizationMode.js"}}

0 comments on commit ecdb48c

Please sign in to comment.