Bar Chart

Preview

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/bar-chart

API Reference

BarChart

series
readonly XYSeries[]

Nonnegative values aligned with categories. Missing or negative values leave a gap.

Default—
categories
readonly string[]

Unique category labels in display order.

Default—
layout?
"grouped" | "stacked"
Default—
orientation?
"vertical" | "horizontal"
Default—
sort?
"none" | "ascending" | "descending"

Order categories by their visible total. Bars glide to their new place when it changes.

Default—
max?
number

Fixed top of the value axis. Defaults to a rounded value above the tallest bar.

Default—
activeId?
string | null

Inspected category, by label.

Default—
defaultActiveId?
string | null
Default—
onActiveChange?
((id: string | null) => void)
Default—
hiddenSeries?
readonly string[]

Series ids hidden through the legend.

Default—
defaultHiddenSeries?
readonly string[]
Default—
onHiddenSeriesChange?
((ids: readonly string[]) => void)
Default—
formatValue?
((value: number) => string)
Default—
formatTick?
((value: number) => string)

Axis tick labels. Defaults to compact notation (1.2K).

Default—
label?
string
Default—
labels?
Partial<{ label: string; inspect: string; } & { noData: string; missing: string; dataCaption: string; category: string; total: string; series: string; seriesValue: string; totalValue: string; }>

Override any built-in string, including the shared `xyChart` ones.

Default—
className?
string
Default—

BarChartLegend

className?
string
Default—

BarChartPlot

height?
number

Plot height in px. Horizontal charts default to 36px per category.

Default—
labelWidth?
number

Width of the category label gutter for horizontal bars, in px.

Default96
showGrid?
boolean
Defaulttrue
className?
string
Default—

BarChartTooltip

className?
string
Default—
side?
"top" | "right" | "bottom" | "left"
Defaulttop

Updated