// --------------------------------------------------------------------------- // SegmentedBar — thin horizontal status distribution strip. // // A single bar split into N color segments showing the share of each // status. The legend below the bar shows the segment label + count + // percentage, color-coded to the segment. Designed for 4–6 statuses. // --------------------------------------------------------------------------- import { fmt } from "@/lib/format"; export interface Segment { id: string; label: string; count: number; color: string; } export interface SegmentedBarProps { segments: Segment[]; /** Optional caption shown above the bar (e.g. "Status distribution"). */ caption?: string; } export function SegmentedBar({ segments, caption }: SegmentedBarProps) { const total = segments.reduce((s, x) => s + x.count, 0); if (total <= 0) { return (
No claims yet.
); } return (
{caption ? (
{caption}
) : null} {/* The bar */}
{segments.map((s, i) => { const pct = (s.count / total) * 100; if (pct <= 0) return null; return (
); })}
{/* Legend */}
); }