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
99
100
101import * as React from 'react';
import { BarChart, BarChartProps } from '@mui/x-charts/BarChart';
import Typography from '@mui/material/Typography';
const dataset = [
[3, -7, 'First'],
[0, -5, 'Second'],
[10, 0, 'Third'],
[9, 6, 'Fourth'],
[1, 0, 'Fifth'],
[0, -1, 'Sixth'],
[1, -1, 'Seventh'],
[2, -2, 'Eighth'],
].map(([high, low, order]) => ({
high,
low,
order,
}));
const seriesH = [
{ dataKey: 'high', label: 'High', layout: 'horizontal', stack: 'stack' },
{ dataKey: 'low', label: 'Low', layout: 'horizontal', stack: 'stack' },
] satisfies BarChartProps['series'];
const seriesV = [
{ dataKey: 'high', label: 'High', stack: 'stack' },
{ dataKey: 'low', label: 'Low', stack: 'stack' },
] satisfies BarChartProps['series'];
const chartSettingsH = {
margin: { left: 32 },
dataset,
width: 400,
height: 400,
series: seriesH,
yAxis: [{ scaleType: 'band', dataKey: 'order', width: 12 }],
hideLegend: true,
} satisfies BarChartProps;
const chartSettingsV = {
...chartSettingsH,
margin: { left: 0 },
xAxis: [{ dataKey: 'order', height: 8 }],
yAxis: undefined,
series: seriesV,
} satisfies BarChartProps;
export default function BarBorderRadius() {
return (
<div style={{ display: 'grid', gap: 2, gridTemplateColumns: 'auto repeat(2, 1fr)' }}>
<div />
<Typography sx={{ justifySelf: 'center' }}>Layout: Vertical</Typography>
<Typography sx={{ justifySelf: 'center' }}>Layout: Horizontal</Typography>
<Typography
sx={{
writingMode: 'vertical-lr',
rotate: '180deg',
alignSelf: 'center',
justifySelf: 'center',
}}
>
Border Radius: 4px
</Typography>
<BarChart {...chartSettingsV} borderRadius={4} />
<BarChart {...chartSettingsH} borderRadius={4} />
<Typography
sx={{
writingMode: 'vertical-lr',
rotate: '180deg',
alignSelf: 'center',
justifySelf: 'center',
}}
>
Border Radius: 16px
</Typography>
<BarChart {...chartSettingsV} borderRadius={16} />
<BarChart {...chartSettingsH} borderRadius={16} />
<Typography
sx={{
writingMode: 'vertical-lr',
rotate: '180deg',
alignSelf: 'center',
justifySelf: 'center',
}}
>
Border Radius: 100px
</Typography>
<BarChart {...chartSettingsV} borderRadius={100} />
<BarChart {...chartSettingsH} borderRadius={100} />
<Typography
sx={{
writingMode: 'vertical-lr',
rotate: '180deg',
alignSelf: 'center',
justifySelf: 'center',
}}
>
Axis Reversed + Border Radius: 16px
</Typography>
<BarChart {...chartSettingsV} yAxis={[{ reverse: true }]} borderRadius={16} />
<BarChart {...chartSettingsH} xAxis={[{ reverse: true }]} borderRadius={16} />
</div>
);
}