BarChart
Responsive bar chart with support for vertical, horizontal, stacked, and grouped variants.
Playground
Props
| Prop | Type | Default | Value |
|---|---|---|---|
categoryKey* | string | β | |
bars* | BarConfig[] | β | β |
horizontal | boolean | β | |
stacked | boolean | β | |
barSize | number | β | |
barGap | number | β | |
barCategoryGap | string | number | β | |
xAxis | AxisConfig | β | β |
yAxis | AxisConfig | β | β |
Usage
// Simple bar chart
<BarChart
data={salesData}
categoryKey="month"
bars={[{ dataKey: 'revenue', name: 'Revenue' }]}
/>
// Stacked bar chart
<BarChart
data={salesData}
categoryKey="month"
bars={[
{ dataKey: 'product', name: 'Products', stackId: 'sales' },
{ dataKey: 'services', name: 'Services', stackId: 'sales' },
]}
stacked
/>
// Horizontal bar chart
<BarChart
data={salesData}
categoryKey="category"
bars={[{ dataKey: 'value' }]}
horizontal
/>