BarChart

Vertical and horizontal bar charts with support for single series, grouped bars, and stacked bars.

Playground

Experiment with different settings:

Props

Midnight
OffOn
4
Code
<BarChart
  data={data}
  theme="midnight"
  orientation="vertical"
  barRadius={4}
/>

Grouped Bars

Pass an array of keys to create grouped bars:

revenue
expenses
JanFebMarAprMayJun
tsx
<BarChart
  data={data}
  dataKey={['revenue', 'expenses']}
  categoryKey="month"
  theme="midnight"
/>

Horizontal Bars

$65K$78K$92K$85KJanFebMarApr

Props

PropTypeDefaultDescription
data*T[]-Data array
dataKey*keyof T | (keyof T)[]-Key(s) for bar values
categoryKey*keyof T-Key for category axis
widthnumber500Chart width
heightnumber300Chart height
theme*ThemeName-Theme name
orientation"vertical" | "horizontal""vertical"Bar orientation
showLabelsbooleanfalseShow value labels
format(value: number) => string-Value formatter
barGapnumber0.1Gap between bars (0-1)
groupGapnumber0.2Gap between groups (0-1)
barRadiusnumber4Bar border radius