import React from 'react' import { Box, Group, Stack, Text } from '@mantine/core' export interface BarChartDatum { label: React.ReactNode value: number /** Mantine color key for the bar (e.g. 'teal', 'red'). Defaults to the theme primary. */ color?: string } export interface BarChartProps { data: BarChartDatum[] /** Format the numeric value shown at the end of each bar. */ valueFormatter?: (value: number) => string } // A dependency-free horizontal bar chart (CSS only, theme colours). Feed it // aggregated counts from a stats RPC — no charting library to install or break. export function BarChart({ data, valueFormatter }: BarChartProps) { const max = Math.max(1, ...data.map((d) => d.value)) const fmt = valueFormatter ?? ((n: number) => String(n)) return ( {data.map((datum, index) => ( {datum.label} {fmt(datum.value)} ))} ) }