Skip to content

Commit 1e5a474

Browse files
committed
Add keynumber charts
1 parent 83c2c4c commit 1e5a474

File tree

2 files changed

+94
-8
lines changed

2 files changed

+94
-8
lines changed

src/Dashboard/KeyNumbers/KeyNumbers.js

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import clsx from 'clsx'
33
import PropTypes from 'prop-types'
44
import { makeStyles } from '@material-ui/core/styles'
55
import { Paper, Grid, Typography } from '@material-ui/core'
6+
import { Line } from 'react-chartjs-2'
7+
8+
import { subscriptionsTrendChart } from './data'
69

710
const KeyNumbers = props => {
811
const classes = useStyles()
@@ -11,62 +14,90 @@ const KeyNumbers = props => {
1114
<>
1215
<Grid item xs={6} sm={3}>
1316
<Paper className={classes.paper}>
14-
Subscriptions
1517
<Grid container spacing={0}>
1618
<Grid item xs={6} md={12} lg={6}>
19+
<Typography variant="body2">Subscriptions</Typography>
1720
<Typography variant="body1" className={classes.value}>
1821
139 <sup className={clsx(classes.valueChange, classes.positive)}>+5%</sup>
1922
</Typography>
2023
</Grid>
2124
<Grid item xs={6} md={12} lg={6}>
22-
-
25+
<div className={classes.chartContainer}>
26+
<div className={classes.chart}>
27+
<Line
28+
data={subscriptionsTrendChart.data}
29+
options={subscriptionsTrendChart.options}
30+
/>
31+
</div>
32+
</div>
2333
</Grid>
2434
</Grid>
2535
</Paper>
2636
</Grid>
2737
<Grid item xs={6} sm={3}>
2838
<Paper className={classes.paper}>
29-
Monthly Revenue
3039
<Grid container spacing={0}>
3140
<Grid item xs={6} md={12} lg={6}>
41+
<Typography variant="body2">Monthly Revenue</Typography>
3242
<Typography variant="body1" className={classes.value}>
3343
24350${' '}
3444
<sup className={clsx(classes.valueChange, classes.positive)}>+13%</sup>
3545
</Typography>
3646
</Grid>
3747
<Grid item xs={6} md={12} lg={6}>
38-
-
48+
<div className={classes.chartContainer}>
49+
<div className={classes.chart}>
50+
<Line
51+
data={subscriptionsTrendChart.data}
52+
options={subscriptionsTrendChart.options}
53+
/>
54+
</div>
55+
</div>
3956
</Grid>
4057
</Grid>
4158
</Paper>
4259
</Grid>
4360
<Grid item xs={6} sm={3}>
4461
<Paper className={classes.paper}>
45-
Monthly Churn
4662
<Grid container spacing={0}>
4763
<Grid item xs={6} md={12} lg={6}>
64+
<Typography variant="body2">Monthly Churn</Typography>
4865
<Typography variant="body1" className={classes.value}>
4966
13 <sup className={clsx(classes.valueChange, classes.negative)}>+10%</sup>
5067
</Typography>
5168
</Grid>
5269
<Grid item xs={6} md={12} lg={6}>
53-
-
70+
<div className={classes.chartContainer}>
71+
<div className={classes.chart}>
72+
<Line
73+
data={subscriptionsTrendChart.data}
74+
options={subscriptionsTrendChart.options}
75+
/>
76+
</div>
77+
</div>
5478
</Grid>
5579
</Grid>
5680
</Paper>
5781
</Grid>
5882
<Grid item xs={6} sm={3}>
5983
<Paper className={classes.paper}>
60-
Total Users
6184
<Grid container spacing={0}>
6285
<Grid item xs={6} md={12} lg={6}>
86+
<Typography variant="body2">Total Users</Typography>
6387
<Typography variant="body1" className={classes.value}>
6488
48205{' '}
6589
<sup className={clsx(classes.valueChange, classes.positive)}>+30%</sup>
6690
</Typography>
6791
</Grid>
6892
<Grid item xs={6} md={12} lg={6}>
69-
-
93+
<div className={classes.chartContainer}>
94+
<div className={classes.chart}>
95+
<Line
96+
data={subscriptionsTrendChart.data}
97+
options={subscriptionsTrendChart.options}
98+
/>
99+
</div>
100+
</div>
70101
</Grid>
71102
</Grid>
72103
</Paper>
@@ -97,6 +128,18 @@ const useStyles = makeStyles(theme => ({
97128
positive: {
98129
color: theme.palette.text.positive,
99130
},
131+
chartContainer: {
132+
width: '100%',
133+
position: 'relative',
134+
paddingBottom: '25%',
135+
},
136+
chart: {
137+
position: 'absolute',
138+
width: '100%',
139+
height: '100%',
140+
top: 0,
141+
left: 0,
142+
},
100143
}))
101144

102145
export default KeyNumbers

src/Dashboard/KeyNumbers/data.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
export const subscriptionsTrendChart = {
2+
data: {
3+
datasets: [
4+
{
5+
backgroundColor: '#ae59e3',
6+
borderColor: '#ae59e3',
7+
// backgroundColor: 'rgba(136, 151, 170, 0.1)',
8+
borderWidth: 2,
9+
label: 'Subscriptions',
10+
fill: false,
11+
data: [1545, 1350, 1270, 1830, 1955, 1865, 2034, 2544, 1956, 2211, 1540, 1670],
12+
},
13+
],
14+
labels: Array(12).fill(''),
15+
},
16+
options: {
17+
legend: {
18+
display: false,
19+
},
20+
scales: {
21+
xAxes: [
22+
{
23+
display: false,
24+
},
25+
],
26+
yAxes: [
27+
{
28+
display: false,
29+
},
30+
],
31+
},
32+
tooltips: {
33+
mode: 'index',
34+
intersect: false,
35+
},
36+
hover: {
37+
mode: 'index',
38+
intersect: false,
39+
},
40+
responsive: true,
41+
maintainAspectRatio: false,
42+
},
43+
}

0 commit comments

Comments
 (0)