BarChart
BarChart is the cartesian container for Bar series. It owns the
chart's layout, scales, and interaction state; children like XAxis, CartesianGrid
and Tooltip register themselves into it.
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip } from "solid-recharts";
<BarChart width={500} height={300} data={data}>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="name" />
<YAxis />
<Tooltip />
<Bar dataKey="uv" fill="#82ca9d" />
</BarChart>;
Loading source...
Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | object[] | — | Source data array, one entry per x position |
width, height | number | — | Fixed size (omit when inside ResponsiveContainer) |
layout | "horizontal" | "vertical" | "horizontal" | Direction of the independent axis |
margin | { top, right, bottom, left } | { 5, 5, 5, 5 } | Space around the plot area |
syncId | string | — | Sync tooltip/brush across charts sharing the id |
onClick, onMouseMove, … | function | — | Chart-level mouse events with the active payload |
All other recharts BarChart props are supported; see the
recharts BarChart docs for the full matrix.
Notes
- Multiple
Barchildren are rendered side-by-side (grouped) unless you set astackId. - Set the same
stackIdon two or moreBarchildren to stack them. - Use the
radiusprop to round the top corners:radius={[4, 4, 0, 0]}. - Set
syncIdon two charts to mirror tooltips and brushes between them.
See also
- Bar — the series component and its shape/label options
- XAxis · YAxis
- ComposedChart — mix bars with lines and areas