Skip to content
SENVENLI UI

Bar chart

Values per category or period as bars, grouped or stacked, vertical or horizontal.
Revenue by quarter
import { BarChart } from "@senvenli/react/charts";

Examples

Stacked

Parts of each period's total; at most five parts per stack.

Horizontal

Long category names, ranked by value with the figure at the bar's end.

With a target line

Whole counts on the axis and a reference line to read them against.

Waterfall: From revenue to profit

An opening total, the changes in order, and the closing total.

Waterfall: A net change

Without a start, the running total begins at zero.

Guidelines

When to use it

  • Comparing values across categories or periods.
  • Explaining a change between two totals.

Use something else when

  • A ranked list of names with values reads better. Bar list

Accessibility

Keyboard

KeysWhat happens
Arrow left / rightMoves between data points; the tooltip follows.

Built in

  • A "Show as table" button shows the same data as a table, which screen readers get by default.

You provide

  • A title that says what the figure is.

API reference

BarChart

title
string

What the chart shows ("Income and expenses"), over it; leave it out when a card or a heading already says so.

aria-label
string

Names the chart when it has no visible title.

period
string

The period it covers ("September 2026").

isLoading
boolean
emptyState
React.ReactNode

Shown instead of the plot when there is no data: an EmptyState size="small" or text; "No data" by default.

start
WaterfallChartStep

The opening total ("Opening balance"), a total bar from zero; the running total starts at 0 without it. A start without a finite value (NaN, ±Infinity) is left out the same way, with a warning in the console: no start bar, the running total starts at 0, and the end total is the finite steps' sum (never NaN).

steps
readonly WaterfallChartStep[]

The changes, in order: a positive value raises the running total, a negative one lowers it, and a zero leaves it (a neutral step: a flat 1.5px line at the running total, labeled "€ 0" with no sign, and no legend key of its own). Steps without a finite value are left out, with a warning in the console. When nothing moves off zero (no step, or every figure zero, start included), the chart counts it as nothing measured and shows the empty state.

endLabel
string

The closing total's name ("Net"): a total bar from zero to the start plus every step.

valueFormatter
ChartValueFormatter

Shared by the axis, the labels, the tooltip and the table ("€ 48.920"). Changes and a negative total are formatted by their size with a + or − before them, so the formatter sees non-negative values there.

height
number

The plot's height in px; 240 by default.

type
"waterfall" | "percent" | "grouped" | "stacked"

waterfall: a start, the steps up and down, and the end, each bar starting where the last one ended.

total
React.ReactNode

The headline figure, in metric-medium ("€ 184,2k").

data
readonly T[]
index
keyof T & string

The x key: the period or category of each row.

categories
readonly (keyof T & string)[]

The series keys, in order; the first is the product's own figure (ds-chart-1).

labels
Readonly<Partial<Record<string, string>>>

Series names by key ("web" → "Website"); the key by default.

indexFormatter
(value: unknown) => string

The index label in the tooltip and the table ("August 2026").

indexLabel
string

The index column's header in the data table; "Period" for time charts, "Category" for BarChart.

allowDecimals
boolean

false for whole counts (orders, new customers): the value axis steps by whole numbers, so a small count reads 0 / 1 / 2 / 3, never 0.7 / 1.4 / 2.1. Fractional steps by default. Percent bars keep their 0–100% steps.

layout
"horizontal" | "vertical"

horizontal for long category names, ranked; vertical columns by default.

comparison
keyof T & string

A comparison series (last year): ds-chart-neutral.

sortBy
"none" | "value"

Horizontal bars are sorted by their total unless the categories have a natural order (none).

referenceLines
readonly ChartReferenceLine[]

An average or target line.