forked from Cylo-Traders/Agrocylo-PIP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCampaignSizeChart.tsx
More file actions
49 lines (47 loc) · 1.37 KB
/
Copy pathCampaignSizeChart.tsx
File metadata and controls
49 lines (47 loc) · 1.37 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
import {
Bar,
BarChart,
CartesianGrid,
ResponsiveContainer,
Tooltip,
XAxis,
YAxis,
} from 'recharts';
import type { SizeBucket } from '../../lib/analytics/metrics';
import { CHART_COLORS } from '../../lib/analytics/theme';
import { EmptyChartState } from './ChartCard';
export function CampaignSizeChart({ data }: { data: SizeBucket[] }) {
if (data.length === 0) {
return <EmptyChartState message="No campaigns recorded yet." />;
}
return (
<ResponsiveContainer width="100%" height={280}>
<BarChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>
<CartesianGrid
stroke="#e0cfb0"
strokeDasharray="4 4"
vertical={false}
/>
<XAxis
dataKey="label"
tick={{ fontSize: 11, fill: '#7d5e34' }}
interval={0}
angle={-20}
textAnchor="end"
height={56}
/>
<YAxis
tick={{ fontSize: 12, fill: '#7d5e34' }}
width={32}
allowDecimals={false}
/>
<Tooltip
formatter={(value) => [String(value ?? 0), 'Campaigns']}
labelFormatter={(label) => `Target amount: ${label}`}
contentStyle={{ borderRadius: 8, borderColor: '#e0cfb0' }}
/>
<Bar dataKey="count" fill={CHART_COLORS.amber} radius={[4, 4, 0, 0]} />
</BarChart>
</ResponsiveContainer>
);
}