import type { ReactNode } from 'react'; export type BarChartPoint = { key: string; label: string; value: number; /** Optional secondary value rendered as an overlay (e.g., errors stacked on calls). */ secondary?: number; tooltip: ReactNode; }; export default function BarChart({ points, height = 180, emptyLabel }: { points: BarChartPoint[]; height?: number; emptyLabel: string }) { if (points.length === 0) { return
{emptyLabel}
; } const max = Math.max(...points.map((p) => p.value), 1); return (
{points.map((point) => { const barHeight = (point.value / max) * 100; const overlayHeight = point.secondary !== undefined && point.value > 0 ? (point.secondary / point.value) * barHeight : 0; return (
{point.tooltip}
{overlayHeight > 0 && (
)}
{point.label}
); })}
); }