/** * dashboard-client/src/components/charts/PerfLineChart.tsx — reusable perf line chart. * * Recharts LineChart with the dashboard dark theme (AXIS "#8b949e", * GRID "#30363d", dark tooltip). Renders `{ts, value}` samples over time. * 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, LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, } from "recharts"; export interface PerfLineChartProps { /** Time-series samples ascending by ts (epoch ms). */ data: Array<{ ts: number; value: number }>; /** Optional series label shown in the tooltip. */ label?: string; /** Line + gradient color (default dashboard blue). */ color?: string; /** Chart height in px (default 280). */ height?: number; } const AXIS_COLOR = "#8b949e"; const GRID_COLOR = "#30363d"; const TOOLTIP_STYLE = { background: "#161b22", border: "1px solid #30363d", borderRadius: "6px", color: "#e6edf3", }; function fmtTs(ts: number): string { return new Date(ts).toLocaleTimeString(); } function fmtVal(v: number): string { return Number.isFinite(v) ? String(v) : String(v); } export function PerfLineChart({ data, label = "value", color = "#58a6ff", height = 280, }: PerfLineChartProps): React.ReactElement { if (!data || data.length === 0) { return
No data available
; } const gradId = `perf-line-${color.replace(/[^a-zA-Z0-9]/g, "")}`; return (