import { useRef } from "react"; import { BarChart as RechartsBarChart, Bar, XAxis, YAxis, Tooltip, CartesianGrid, Cell, ResponsiveContainer, Rectangle, } from "recharts"; import { z } from "zod"; import { CHART_COLORS, CHART_CONFIG } from "./chart-config"; export const BarChartProps = z.object({ title: z.string().describe("Chart title"), description: z.string().describe("Brief description or subtitle"), data: z.array( z.object({ label: z.string(), value: z.number(), }), ), }); type BarChartPropsType = z.infer; /** Tracks seen indices so only NEW bars get the fade-in animation. */ function useSeenIndices() { const seen = useRef(new Set()); return { isNew(index: number) { if (seen.current.has(index)) return false; seen.current.add(index); return true; }, }; } // eslint-disable-next-line @typescript-eslint/no-explicit-any function AnimatedBar(props: any) { const { isNew, ...rest } = props; return ( ); } export function BarChart({ title, description, data }: BarChartPropsType) { const { isNew } = useSeenIndices(); if (!data || !Array.isArray(data) || data.length === 0) { return (

{title}

{description}

No data available

); } return (
{/* Scoped keyframe -- no globals.css needed */}

{title}

{description}

{ const p = props as Record; return ; }} > {data.map((_, index) => ( ))}
); }