"use client"; import * as React from "react"; import { CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts"; import { formatMs } from "@/lib/format"; import { AXIS_TICK, CHART_COLORS, CHART_MARGIN, formatBucketLabel, formatTick } from "./chart-theme"; import { ChartTooltip } from "./chart-tooltip"; import { ChartLegend } from "./chart-frame"; export interface LatencyPoint { t: string; p50: number | null; p95: number | null; } /** P50 (accent) and P95 (neutral) latency over time; one axis, gaps where no requests happened. */ export function LatencyLineChart({ data, bucket, height = 240 }: { data: LatencyPoint[]; bucket: "hour" | "day"; height?: number }) { const last = [...data].reverse().find((d) => d.p50 !== null); const tickEvery = Math.max(1, Math.ceil(data.length / (bucket === "hour" ? 8 : 10))); return (