Cartesian
BarChart
Categorical bar chart with grouped, stacked, horizontal, labeled, active, and negative value variants.
Examples
Stacked with metrics
<BarChart
title="Bar Chart - Interactive"
xKey="day"
data={activity}
stacked
metrics={[
{label: 'Running', value: '2,530', color: 'var(--uin-chart-1)'},
{label: 'Swimming', value: '2,550', color: 'var(--uin-chart-2)'}
]}
series={[
{key: 'running', label: 'Running', unit: 'kcal'},
{key: 'swimming', label: 'Swimming', unit: 'kcal'}
]}
/>Grouped
<BarChart
title="Bar Chart - Grouped"
xKey="source"
data={intake}
series={[
{key: 'imported', label: 'Imported'},
{key: 'indexed', label: 'Indexed'},
{key: 'failed', label: 'Failed'}
]}
/>Horizontal
<BarChart
title="Bar Chart - Horizontal"
xKey="source"
data={intake}
orientation="horizontal"
showLabels
series={[{key: 'indexed', label: 'Indexed'}]}
/>Negative values
<BarChart
title="Bar Chart - Negative"
xKey="label"
data={signed}
showLabels
series={[{key: 'net', label: 'Net'}]}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | ChartDatum[] | — | Categorical rows to plot. |
series | ChartSeries[] | — | Bar series config with key, label, color, icon, and unit metadata. |
xKey | string | 'x' | Field used for category labels. |
orientation | 'vertical' | 'horizontal' | 'vertical' | Controls whether bars grow upward or sideways. |
stacked | boolean | false | Stack series in each category instead of grouping them. |
showLabels | boolean | false | Render value labels near each bar. |
negativeColor | string | 'var(--uin-chart-negative)' | Color used for negative values. |
Install
CLI
npm install d3-array d3-scale d3-shape
npx @a3tai/mittsu add bar-chart --registry ./packages/charts/registry.json