-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAreaChart.tsx
69 lines (66 loc) · 1.53 KB
/
AreaChart.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
66
67
68
69
import {
ChartConfig,
ChartContainer,
ChartLegend,
ChartLegendContent,
ChartTooltip,
ChartTooltipContent
} from '@/components/ui/chart';
import { cn } from '@/lib/utils';
import { Area, AreaChart, CartesianGrid, XAxis } from 'recharts';
type ChartData = {
name: string;
value: number;
};
const chartConfig = {
value: {
label: 'Time Spent',
color: 'hsl(var(--chart-1))',
},
} satisfies ChartConfig;
export const AreaChartComponent = ({
chartData,
classname,
}: {
chartData: ChartData[];
classname?: string;
}) => {
return (
<div>
<ChartContainer className={cn(classname)} config={chartConfig}>
<AreaChart
accessibilityLayer
data={chartData}
margin={{
left: 15,
right: 15,
}}
>
<CartesianGrid vertical={false} />
<XAxis
dataKey="name"
tickLine={false}
axisLine={false}
tickMargin={8}
tickFormatter={(value) =>
value.length > 4 ? value.slice(0, 3) : value
}
/>
<ChartTooltip
cursor={true}
content={<ChartTooltipContent indicator="dot" />}
/>
<ChartLegend content={<ChartLegendContent />} />
<Area
dataKey="value"
type="natural"
fill="var(--color-value)"
fillOpacity={0.4}
stroke="var(--color-value)"
stackId="a"
/>
</AreaChart>
</ChartContainer>
</div>
);
};