"use client" import { PieChart, Pie, Cell, ResponsiveContainer, Legend, Tooltip } from "recharts" import { Loader2 } from "lucide-react" interface DetectionDonutChartProps { potholes: number signboards: number isLoading: boolean } const COLORS = { pothole: "#ef4444", signboard: "#3b82f6" } export function DetectionDonutChart({ potholes, signboards, isLoading }: DetectionDonutChartProps) { if (isLoading) { return (
) } const total = potholes + signboards if (total === 0) { return (

No detections found

Process videos to see data

) } const data = [ { name: "Potholes", value: potholes, color: COLORS.pothole }, { name: "Signboards", value: signboards, color: COLORS.signboard } ] return (
{data.map((entry, index) => ( ))} { if (active && payload && payload.length) { const data = payload[0] return (

{data.name}

Count: {data.value}

{((Number(data.value) / total) * 100).toFixed(1)}% of total

) } return null }} /> (
{payload?.map((entry, index) => (
{entry.value}: {data[index].value}
))}
)} /> {/* Center label */}

{total}

Total

) }