Skip to main content

Bar Chart

A bar chart component built using Recharts v3. Supports vertical/horizontal layout, stacked/grouped bars, and customizable styling.

Installation

$ npx shadcn@latest add @orecus/bar-chart
Registry:
@orecus/chart@orecus/color-utils@orecus/chart-utils@orecus/card

Component

Grouped Bar Chart

Default gradient fills with glow effect

Classic Solid Bars

Solid fills without gradient or glow

With Reference Lines

Target and average reference lines

Custom Bar Radius

Bars with larger corner radius

Data Labels

Values displayed directly on bars

Props

PropTypeDefaultDescription
data*any[]The data for the chart
categories*string[]Keys in data to map to bars
index*stringKey in data to use for category axis
colorsThemeColor[]Colors for each category
layout'vertical' | 'horizontal''vertical'Bar orientation
stackedbooleanfalseStack bars on top of each other
barRadiusnumber4Corner radius for bars
barGapnumber4Gap between grouped bars
showDataLabelsbooleanfalseShow value labels directly on bars
showLegendbooleantrueShow chart legend
showGridLinesbooleantrueShow grid lines
actionsReactNodeActions to display in the chart header
cardPropsCardPropsProps to pass to the underlying Card component
tooltipSortByValuebooleanfalseSort tooltip items by value (descending)
tooltipShowTotalbooleanfalseShow total in tooltip for multi-series
tooltipTotalLabelstring'Total'Label for the total row in tooltip
legendIndicator'square' | 'circle' | 'line''square'Shape of legend indicators
interactiveLegendbooleanfalseAllow clicking legend items to toggle series visibility
legendWrapbooleantrueAllow legend items to wrap to multiple lines
xAxisFormatter(value: string) => stringFormatter for x-axis (category axis) tick labels and tooltip header
xAxisTickSVGProps | ReactElement | ((props) => ReactNode) | booleanCustom tick rendering for the category axis — overrides xAxisFormatter when set
yAxisFormatter(value: number) => stringFormatter for y-axis (value axis) tick labels — falls back to valueFormatter
yAxisTickSVGProps | ReactElement | ((props) => ReactNode) | booleanCustom tick rendering for the value axis — overrides yAxisFormatter when set
referenceLinesChartReferenceLine[]Reference lines (targets, thresholds, averages) rendered on the chart