/** * dashboard-client/src/components/PerfChart.tsx — perf stat chart. * * The /api/perf endpoint returns rolling-window aggregates (not time-series), * so this renders a stat-card "chart": p50/p95 latency bars, TPS, cache hit %, * db recompute + disk write. Each metric shows a normalized bar + numeric. */ import type React from "react"; import type { PerfResponse } from "@contracts"; import { Card, CardContent, CardHeader, CardTitle } from "../components/ui/card"; export interface PerfChartProps { perf: PerfResponse; } function fmtMs(n: number): string { return n >= 1000 ? `${(n / 1000).toFixed(1)}s` : `${n.toFixed(0)}ms`; } interface BarProps { /** Current value. */ value: number; /** Value that represents 100% bar fill (the "max" reference). */ max: number; /** Color class. */ colorClass: string; } function Bar({ value, max, colorClass }: BarProps): React.ReactElement { const pct = max > 0 ? Math.max(0, Math.min(100, (value / max) * 100)) : 0; return (