"use client"; import type { TrendPoint } from "@/lib/analytics"; import { cn } from "@/lib/utils"; // A small dependency-free vertical bar chart (matches the spirit of // components/chat/sparkline.tsx). Bars scale to the series max; each shows its // value above and its label below. Themed with semantic tokens. export function BarChart({ data, className, emptyLabel, }: { data: TrendPoint[]; className?: string; emptyLabel: string; }) { const max = Math.max(1, ...data.map((d) => d.count)); const hasData = data.some((d) => d.count > 0); if (data.length === 0 || !hasData) { return (
{emptyLabel}
); } return (
{data.map((d, i) => { const pct = (d.count / max) * 100; return (
{d.count}
0 ? 4 : 0)}%` }} title={`${d.label}: ${d.count}`} />
{d.label}
); })}
); }