Back to Charts

Cartesian

BarChart

Categorical bar chart with grouped, stacked, horizontal, labeled, active, and negative value variants.

Examples

Stacked with metrics

Bar Chart - Interactive Daily activity by type with top-line metrics. Running 2,530 Swimming 2,550 Running Swimming
Bar Chart - InteractiveDaily activity by type with top-line metrics.02004006008001KMonTueWedThuFriSat
Bar Chart - Interactive
dayRunningSwimming
Mon450300
Tue380420
Wed510240
Thu220610
Fri560460
Sat410520
<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

Bar Chart - Grouped Compare pipeline stages side by side. Imported Indexed Failed
Bar Chart - GroupedCompare pipeline stages side by side.0100200300400BooksPDFsWebNotes
Bar Chart - Grouped
sourceImportedIndexedFailed
Books42037818
PDFs26022131
Web18815612
Notes1341264
<BarChart
  title="Bar Chart - Grouped"
  xKey="source"
  data={intake}
  series={[
    {key: 'imported', label: 'Imported'},
    {key: 'indexed', label: 'Indexed'},
    {key: 'failed', label: 'Failed'}
  ]}
/>

Horizontal

Bar Chart - Horizontal Horizontal bars improve label readability. Indexed
Bar Chart - HorizontalHorizontal bars improve label readability.0100200300400BooksPDFsWebNotes378221156126
Bar Chart - Horizontal
sourceIndexed
Books378
PDFs221
Web156
Notes126
<BarChart
  title="Bar Chart - Horizontal"
  xKey="source"
  data={intake}
  orientation="horizontal"
  showLabels
  series={[{key: 'indexed', label: 'Indexed'}]}
/>

Negative values

Bar Chart - Negative Positive and negative values share a zero baseline. Net
Bar Chart - NegativePositive and negative values share a zero baseline.05001,000JanFebMarAprMayJun880-220640-140940720
Bar Chart - Negative
labelNet
Jan880
Feb-220
Mar640
Apr-140
May940
Jun720
<BarChart
  title="Bar Chart - Negative"
  xKey="label"
  data={signed}
  showLabels
  series={[{key: 'net', label: 'Net'}]}
/>

Props

PropTypeDefaultDescription
dataChartDatum[]Categorical rows to plot.
seriesChartSeries[]Bar series config with key, label, color, icon, and unit metadata.
xKeystring'x'Field used for category labels.
orientation'vertical' | 'horizontal''vertical'Controls whether bars grow upward or sideways.
stackedbooleanfalseStack series in each category instead of grouping them.
showLabelsbooleanfalseRender value labels near each bar.
negativeColorstring'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