forked from mui/mui-x
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBorderRadius.js
More file actions
98 lines (94 loc) · 2.8 KB
/
BorderRadius.js
File metadata and controls
98 lines (94 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import * as React from 'react';
import { BarChart } from '@mui/x-charts/BarChart';
import Stack from '@mui/material/Stack';
import { HighlightedCode } from '@mui/internal-core-docs/HighlightedCode';
import TextField from '@mui/material/TextField';
import MenuItem from '@mui/material/MenuItem';
import Slider from '@mui/material/Slider';
import Typography from '@mui/material/Typography';
import Checkbox from '@mui/material/Checkbox';
import FormControlLabel from '@mui/material/FormControlLabel';
export default function BorderRadius() {
const [layout, setLayout] = React.useState('vertical');
const [radius, setRadius] = React.useState(10);
const [reverse, setReverse] = React.useState(false);
return (
<Stack direction="column" spacing={1} sx={{ width: '100%', maxWidth: 600 }}>
<Stack direction="row" spacing={4} flexWrap="wrap" justifyContent="center">
<Stack direction="column" spacing={1} flex={1}>
<Typography gutterBottom>Border Radius</Typography>
<Slider
value={radius}
onChange={(event, value) => setRadius(value)}
valueLabelDisplay="auto"
min={0}
max={50}
sx={{ mt: 2 }}
/>
</Stack>
<TextField
select
sx={{ minWidth: 150 }}
label="layout"
value={layout}
onChange={(event) => setLayout(event.target.value)}
>
<MenuItem value="horizontal">Horizontal</MenuItem>
<MenuItem value="vertical">Vertical</MenuItem>
</TextField>
<FormControlLabel
checked={reverse}
control={
<Checkbox onChange={(event) => setReverse(event.target.checked)} />
}
label="Reverse"
labelPlacement="end"
/>
</Stack>
<BarChart
series={[
{ dataKey: 'high', label: 'High', layout, stack: 'stack' },
{ dataKey: 'low', label: 'Low', layout, stack: 'stack' },
]}
margin={{ left: 0 }}
{...getChartSettings(layout, reverse)}
borderRadius={radius}
/>
<HighlightedCode
code={`<BarChart
// ...
borderRadius={${radius}}
/>`}
language="jsx"
copyButtonHidden
/>
</Stack>
);
}
const dataset = [
[3, -7, '1st'],
[0, -5, '2nd'],
[10, 0, '3rd'],
[9, 6, '4th'],
].map(([high, low, order]) => ({
high,
low,
order,
}));
function getChartSettings(layout, reverse) {
return {
dataset,
height: 300,
xAxis: layout === 'horizontal' ? [{ reverse }] : [{ dataKey: 'order' }],
yAxis:
layout === 'horizontal'
? [{ scaleType: 'band', dataKey: 'order' }]
: [{ reverse }],
slotProps: {
legend: {
direction: 'horizontal',
position: { vertical: 'bottom', horizontal: 'center' },
},
},
};
}