-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Document how to hide the legend (#10951)
- Loading branch information
1 parent
a711a0e
commit e48df4c
Showing
5 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as React from 'react'; | ||
import Stack from '@mui/material/Stack'; | ||
import FormControlLabel from '@mui/material/FormControlLabel'; | ||
import Checkbox from '@mui/material/Checkbox'; | ||
import { PieChart } from '@mui/x-charts/PieChart'; | ||
|
||
const series = [ | ||
{ | ||
data: [ | ||
{ id: 0, value: 10, label: 'series A' }, | ||
{ id: 1, value: 15, label: 'series B' }, | ||
{ id: 2, value: 20, label: 'series C' }, | ||
], | ||
}, | ||
]; | ||
|
||
export default function HiddenLegend() { | ||
const [isHidden, setIsHidden] = React.useState(false); | ||
|
||
return ( | ||
<Stack> | ||
<FormControlLabel | ||
checked={isHidden} | ||
control={ | ||
<Checkbox onChange={(event) => setIsHidden(event.target.checked)} /> | ||
} | ||
label="hide the legend" | ||
labelPlacement="end" | ||
/> | ||
<PieChart | ||
series={series} | ||
slotProps={{ legend: { hidden: isHidden } }} | ||
width={400} | ||
height={200} | ||
/> | ||
</Stack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as React from 'react'; | ||
import Stack from '@mui/material/Stack'; | ||
import FormControlLabel from '@mui/material/FormControlLabel'; | ||
import Checkbox from '@mui/material/Checkbox'; | ||
import { PieChart } from '@mui/x-charts/PieChart'; | ||
|
||
const series = [ | ||
{ | ||
data: [ | ||
{ id: 0, value: 10, label: 'series A' }, | ||
{ id: 1, value: 15, label: 'series B' }, | ||
{ id: 2, value: 20, label: 'series C' }, | ||
], | ||
}, | ||
]; | ||
|
||
export default function HiddenLegend() { | ||
const [isHidden, setIsHidden] = React.useState(false); | ||
|
||
return ( | ||
<Stack> | ||
<FormControlLabel | ||
checked={isHidden} | ||
control={ | ||
<Checkbox onChange={(event) => setIsHidden(event.target.checked)} /> | ||
} | ||
label="hide the legend" | ||
labelPlacement="end" | ||
/> | ||
<PieChart | ||
series={series} | ||
slotProps={{ legend: { hidden: isHidden } }} | ||
width={400} | ||
height={200} | ||
/> | ||
</Stack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<FormControlLabel | ||
checked={isHidden} | ||
control={ | ||
<Checkbox onChange={(event) => setIsHidden(event.target.checked)} /> | ||
} | ||
label="hide the legend" | ||
labelPlacement="end" | ||
/> | ||
<PieChart | ||
series={series} | ||
slotProps={{ legend: { hidden: isHidden } }} | ||
width={400} | ||
height={200} | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters