/** * dashboard-client/src/components/charts/PerfBarChart.tsx — reusable perf bar chart. * * Recharts BarChart with the dashboard dark theme (AXIS "#8b949e", * GRID "#30363d", dark tooltip). Renders `{label, value}` buckets. * Handles empty data with a "No data available" message. * * PREVENT-PI-004: recharts is bundled into this localhost-served static * dashboard bundle; it makes no runtime network calls. */ import type React from "react"; import { ResponsiveContainer, BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, } from "recharts"; export interface PerfBarChartProps { /** Buckets with a display label + numeric value. */ data: Array<{ label: string; value: number }>; /** Bar color (default dashboard green). */ color?: string; /** Chart height in px (default 280). */ height?: number; /** Optional formatter for values (e.g. "$" prefix, thousands separators). */ valueFormatter?: (v: number) => string; } const AXIS_COLOR = "#8b949e"; const GRID_COLOR = "#30363d"; const TOOLTIP_STYLE = { background: "#161b22", border: "1px solid #30363d", borderRadius: "6px", color: "#e6edf3", }; export function PerfBarChart({ data, color = "#3fb950", height = 280, valueFormatter, }: PerfBarChartProps): React.ReactElement { const fmt = valueFormatter ?? ((v: number) => String(v)); if (!data || data.length === 0) { return

No data available

; } return ( fmt(v)} /> [fmt(value as number), "value"] as [string, string]} contentStyle={TOOLTIP_STYLE} labelStyle={{ color: AXIS_COLOR, fontSize: 12 }} /> ); }