forked from mui/toolpad
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPageViewsBarChart.tsx
More file actions
81 lines (80 loc) · 2.48 KB
/
PageViewsBarChart.tsx
File metadata and controls
81 lines (80 loc) · 2.48 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
import * as React from 'react';
import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import Chip from '@mui/material/Chip';
import Typography from '@mui/material/Typography';
import Stack from '@mui/material/Stack';
import { BarChart } from '@mui/x-charts/BarChart';
import { useTheme } from '@mui/material/styles';
export default function PageViewsBarChart() {
const theme = useTheme();
const colorPalette = [
(theme.vars || theme).palette.primary.dark,
(theme.vars || theme).palette.primary.main,
(theme.vars || theme).palette.primary.light,
];
return (
<Card variant="outlined" sx={{ width: '100%' }}>
<CardContent>
<Typography component="h2" variant="subtitle2" gutterBottom>
Page views and downloads
</Typography>
<Stack sx={{ justifyContent: 'space-between' }}>
<Stack
direction="row"
sx={{
alignContent: { xs: 'center', sm: 'flex-start' },
alignItems: 'center',
gap: 1,
}}
>
<Typography variant="h4" component="p">
1.3M
</Typography>
<Chip size="small" color="error" label="-8%" />
</Stack>
<Typography variant="caption" sx={{ color: 'text.secondary' }}>
Page views and downloads for the last 6 months
</Typography>
</Stack>
<BarChart
borderRadius={8}
colors={colorPalette}
xAxis={
[
{
scaleType: 'band',
categoryGapRatio: 0.5,
data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
},
] as any
}
series={[
{
id: 'page-views',
label: 'Page views',
data: [2234, 3872, 2998, 4125, 3357, 2789, 2998],
stack: 'A',
},
{
id: 'downloads',
label: 'Downloads',
data: [3098, 4215, 2384, 2101, 4752, 3593, 2384],
stack: 'A',
},
{
id: 'conversions',
label: 'Conversions',
data: [4051, 2275, 3129, 4693, 3904, 2038, 2275],
stack: 'A',
},
]}
height={250}
margin={{ left: 50, right: 0, top: 20, bottom: 20 }}
grid={{ horizontal: true }}
hideLegend
/>
</CardContent>
</Card>
);
}