forked from mui/mui-x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBarGap.tsx
65 lines (62 loc) · 1.53 KB
/
BarGap.tsx
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
import * as React from 'react';
import ChartsUsageDemo from 'docsx/src/modules/components/ChartsUsageDemo';
import { BarChart } from '@mui/x-charts/BarChart';
import { balanceSheet, addLabels } from './netflixsBalanceSheet';
const series = addLabels([
{ dataKey: 'totAss' },
{ dataKey: 'totLia', stack: 'passive' },
{ dataKey: 'totEq', stack: 'passive' },
]);
export default function BarGap() {
return (
<ChartsUsageDemo
componentName="Bar gap"
data={{
categoryGapRatio: {
knob: 'number',
defaultValue: 0.3,
step: 0.1,
min: 0,
max: 1,
},
barGapRatio: {
knob: 'number',
defaultValue: 0.1,
step: 0.1,
min: -2,
max: 5,
},
}}
renderDemo={(props) => (
<BarChart
dataset={balanceSheet}
series={series}
height={300}
xAxis={[
{
dataKey: 'year',
categoryGapRatio: props.categoryGapRatio,
barGapRatio: props.barGapRatio,
},
]}
yAxis={[{ valueFormatter: (v: number) => `$ ${v / 1000000}B` }]}
hideLegend
/>
)}
getCode={({ props }) => {
return `import { BarChart } from '@mui/x-charts/BarChart';
<BarChart
// ...
xAxis={[
{
scaleType: 'band',
data: ['Page 1', 'Page 2', 'Page 3'],
categoryGapRatio: ${props.categoryGapRatio},
barGapRatio: ${props.barGapRatio},
},
]}
/>`;
}}
/>
);
}