Native Solid 2 fork of solid-recharts (MIT, © Thomas Guehenneux), derived from Recharts (MIT, © recharts). Adapted documentation; neither project endorses this fork.
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.
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 |
The base API follows Recharts 3.9.2 (reference commit b3451050), with the selected next-suite additions; this is not full Recharts 3.10.1 parity. See the Recharts BarChart reference.
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.
Legend and axis layout
This example places the legend outside the plot with position="bottom" and offset={8}. position accepts the exported CartesianPosition type and overrides align/verticalAlign; omitted position preserves their existing behavior. offset defaults to 0. layout defaults to "auto": vertical for left, right, insideLeft, and insideRight, horizontal otherwise.
Outside legends reserve their measured size; inside legends reserve none. With position supplied and the default mount, the wrapper renders legend HTML on the server, and the first client styles retain its zero measured box before measurement. Outside placement adjusts after browser measurement; inside placement is measurement-independent. No-position legends and explicit custom portals retain the existing DOM-only path, without server legend markup. The playground switches between inside and outside placement.
XAxis height="auto" uses a 30px server/first-client fallback, then measures rotated tick labels and the string label. The rounded height includes the tallest tick, tickSize, tickMargin, and the label's height plus 5px when present. Custom render-function labels do not use auto measurement. Pass custom JSX through a render function, not as a raw JSX label value. Requested numeric heights and tick positions are unchanged, but corrected server plot clips can change SSR markup. Automatic height is not server-final geometry. See LineChart's layout details and SSR.
See also
- Bar — the series component and its shape/label options
- XAxis · YAxis
- ComposedChart — mix bars with lines and areas