"use client" import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend } from "recharts" import { Loader2 } from "lucide-react" interface LocationData { name: string defected_sign_board: number pothole: number road_crack: number damaged_road_marking: number good_sign_board: number total: number } interface LocationBarChartProps { data: LocationData[] isLoading: boolean } const COLORS = { defected_sign_board: "#60a5fa", // Lighter Blue pothole: "#ff8a8a", // Lighter Red road_crack: "#fbbf24", // Lighter Orange damaged_road_marking: "#818cf8", // Lighter Indigo good_sign_board: "#34d399" // Lighter Emerald } export function LocationBarChart({ data, isLoading }: LocationBarChartProps) { if (isLoading) { return (
) } if (data.length === 0) { return (

No location data available

Process videos to see detections by location

) } return (
{ if (active && payload && payload.length) { return (

{label}

{payload.map((entry, index) => (
{(entry.name as string).replace(/_/g, ' ')}: {entry.value}
))}
) } return null }} /> (
{payload?.map((entry, index) => (
{(entry.value as string).replace(/_/g, ' ')}
))}
)} />
) }