import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Cell } from 'recharts'; import type { QuantityAggregation } from '@/types'; interface QuantityChartProps { data: QuantityAggregation[]; loading?: boolean; } const QUANTITY_COLORS: Record = { minimal: '#10b981', // green moderate: '#f59e0b', // amber significant: '#f97316', // orange severe: '#ef4444', // red }; const QUANTITY_LABELS: Record = { minimal: 'Minimal', moderate: 'Moderate', significant: 'Significant', severe: 'Severe', }; export function QuantityChart({ data, loading }: QuantityChartProps) { if (loading) { return (
); } if (!data || data.length === 0) { return (

Quantity Estimation

No data available for the selected period
); } // Format data for the chart const chartData = data.map(item => ({ name: QUANTITY_LABELS[item.quantity] || item.quantity, count: item.count, percentage: item.percentage, quantity: item.quantity, })); return (

Litter Quantity Distribution

[ `${value} reports (${props.payload.percentage.toFixed(1)}%)`, 'Count' ]} contentStyle={{ backgroundColor: '#fff', border: '1px solid #e5e7eb', borderRadius: '0.5rem', padding: '0.75rem' }} /> {chartData.map((entry, index) => ( ))}
); }