"use client"; import * as React from "react"; import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts"; import { formatCompact, formatNumber } 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 RequestsBarPoint { t: string; success: number; failed: number; } /** Stacked success/failed bars per bucket. Legend + 1px surface gap between segments keep the two readable without color. */ export function RequestsBarChart({ data, bucket, height = 240 }: { data: RequestsBarPoint[]; bucket: "hour" | "day"; height?: number }) { const totalSuccess = data.reduce((a, d) => a + d.success, 0); const totalFailed = data.reduce((a, d) => a + d.failed, 0); const tickEvery = Math.max(1, Math.ceil(data.length / (bucket === "hour" ? 8 : 10))); return (