-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathMonthlyDownloadsChart.tsx
45 lines (41 loc) · 1.17 KB
/
MonthlyDownloadsChart.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
import { useContext } from 'react';
import { Area, AreaChart, ResponsiveContainer, Tooltip, XAxis } from 'recharts';
import { ThemeContext } from '../pages/_app';
// copied from tailwind.config.js
const colors = {
'dc-navy': '#05192D',
'dc-yellow': '#FCCE0D',
};
type Props = {
monthlyDownloads: Array<{ downloads: number; month: string }>;
};
export default function MonthlyDownloadsChart({ monthlyDownloads }: Props) {
const { theme } = useContext(ThemeContext);
return (
<ResponsiveContainer height={50} width="100%">
<AreaChart
data={monthlyDownloads}
margin={{
bottom: 0,
left: 5,
right: 5,
top: 5,
}}
>
<XAxis dataKey="month" hide />
<Area
dataKey="downloads"
fill={theme === 'light' ? colors['dc-navy'] : colors['dc-yellow']}
name="Downloads"
stroke={theme === 'light' ? colors['dc-navy'] : colors['dc-yellow']}
type="monotone"
/>
<Tooltip
contentStyle={
theme === 'light' ? {} : { backgroundColor: colors['dc-navy'] }
}
/>
</AreaChart>
</ResponsiveContainer>
);
}