Charts guide
BarChart
Grouped vertical or horizontal SVG bars.
Install
npx shadcn@latest add @foldcn/bar-chartBarChart parameters
| Parameter | Type / props | Behavior |
|---|---|---|
data | ReadonlyArray<Datum> | undefined | Rows used by series and axis dataKey accessors. Scatter can supply data on each series. |
children | CartesianChild[] | Descriptors for series, axes, grid, tooltip, and legend. |
defs | Html[] | SVG definitions such as gradients referenced by a series fill. |
width / height | number | SVG dimensions. Defaults to 700 × 433. |
responsive | boolean | Fits the SVG to the available width. |
layout | horizontal | vertical | Changes the category direction. |
margin | { top?, right?, bottom?, left? } | Plot margins in pixels. |
barGap / barCategoryGap | number | Bar spacing parameters; barGap applies to grouped bars. |
stackOffset | sign | expand | Separates signed stacks or normalizes stacked area values to 100%. |
activeLabels | boolean | Shows the active row values beside each series point. |
accessibilityLayer | boolean | Enables keyboard focus and arrow, Home, End, and Escape navigation. |
activeIndex / onActiveIndexChange | number | null / callback | Caller-owned active tooltip state. |
onLegendHover / onLegendClick | callbacks | Dispatches legend focus and click actions for interactive series. |
brushRange / brushDataLength | [start, end] / number | Shows a controlled Brush window against the full data length. |
onBrushStart / onBrushEnd | callbacks | Dispatches Brush handle dragging so the caller can update its visible data window. |
title / className | string | Accessible SVG label and wrapper class. |
Child components
| Parameter | Type / props | Behavior |
|---|---|---|
Area / Bar / Scatter | dataKey, data, name, stroke, fill, type, stackId, yAxisId, hide, zDataKey, radius, cells, background, activeBar, shape, symbols, symbolColors, symbolSize, line, lineJointType, labelDataKey, label, labelFormatter, animationKind, animationDuration, animationKey, animationMatchBy, animationVariant, animationExitDatum | Renders a numeric series. Area supports fillOpacity and connectNulls; Bar supports ranges, per-row cells, background tracks, activeBar, barSize, radius, and minPointSize; Scatter supports row data, Z sizing, symbols, labels, and joined lines. Matching stackIds stack Area or Bar series. Animation options cover the included source examples. |
Line | dataKey, name, stroke, type, dot, hide, legendType | Renders a line series in ComposedChart; legendType none omits its legend entry. |
ZAxis | dataKey, range | Maps scatter Z values to bubble area. |
XAxis / YAxis | dataKey, type, scale, domain, padding, hide, tick, tickCount, niceTicks, width, height, interval, tickAngle, tickFormatter, label, xAxisId, yAxisId, orientation, mirror, unit | Category and numeric axes. |
CartesianGrid | horizontal, vertical, stroke, strokeDasharray | Plot grid. |
Tooltip / Legend | formatter, labelFormatter / align, position, wrapperStyle | Displays active values and a series key. |
ReferenceLine | x, y, stroke, strokeDasharray | Marks a category or numeric value. |
Brush | dataKey, height, stroke | Draws a range track below a Bar or Line chart. |
Supports grouped, stacked, range, and custom-shaped bars, separate left and right numeric axes, secondary X-axis tick callbacks, scroll growth, and example streaming animations. Default transition timing remains approximate.
Examples
The first example is open. Expand Source inside an example to view its code. Other examples load when opened.