Skip to content

[charts][docs] Add docs for rounded symbol #15324

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

Merged
merged 5 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/data/charts/legend/LegendRoundedSymbol.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as React from 'react';
import { PieChart } from '@mui/x-charts/PieChart';
import { legendClasses } from '@mui/x-charts/ChartsLegend';

const series = [
{
data: [
{ id: 0, value: 10, label: 'series A' },
{ id: 1, value: 15, label: 'series B' },
{ id: 2, value: 20, label: 'series C' },
{ id: 3, value: 30, label: 'series D' },
],
},
];

export default function LegendRoundedSymbol() {
return (
<PieChart
series={series}
width={400}
height={200}
sx={{
[`& .${legendClasses.mark}`]: {
ry: '50%',
},
}}
/>
);
}
29 changes: 29 additions & 0 deletions docs/data/charts/legend/LegendRoundedSymbol.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as React from 'react';
import { PieChart } from '@mui/x-charts/PieChart';
import { legendClasses } from '@mui/x-charts/ChartsLegend';

const series = [
{
data: [
{ id: 0, value: 10, label: 'series A' },
{ id: 1, value: 15, label: 'series B' },
{ id: 2, value: 20, label: 'series C' },
{ id: 3, value: 30, label: 'series D' },
],
},
];

export default function LegendRoundedSymbol() {
return (
<PieChart
series={series}
width={400}
height={200}
sx={{
[`& .${legendClasses.mark}`]: {
ry: '50%',
},
}}
/>
);
}
10 changes: 10 additions & 0 deletions docs/data/charts/legend/LegendRoundedSymbol.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<PieChart
series={series}
width={400}
height={200}
sx={{
[`& .${legendClasses.mark}`]: {
ry: '50%',
},
}}
/>
7 changes: 7 additions & 0 deletions docs/data/charts/legend/legend.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ Style applied by other means will not be taken into account.
Which can lead to label overflow.
:::

### Rounded symbol

To create a rounded symbol, use the `legendClasses.mark` to apply CSS on marks.
Notice that SVG `rect` uses `ry` property to control the symbol's corner radius instead of `border-radius`.

{{"demo": "LegendRoundedSymbol.js"}}

## Color legend

To display legend associated to a [colorMap](https://mui.com/x/react-charts/styling/#values-color), you can use:
Expand Down
Loading