Bar chart

A React component in Beamline's Charts & data-vis category.

Amounts by category as bars: columns or rows, grouped, stacked or as shares, reference lines, five looks (rounded, cells, trace, isometric, monospace), a header readout and a highlighted bar, on one data API; a missing value is a stub in its slot, never a zero bar.

Use it for

  • Comparing amounts across categories or periods (signups per month, pipeline by stage).
  • Long category names (rows).

Not for

Anatomy

  • title and description (figcaption; can be visually hidden)
  • actions slot (range, type)
  • legend (toggle buttons)
  • table button
  • plot
  • tooltip
  • bars
  • missing-value stubs (8 px hatched slot at the baseline)
  • reference lines (label just past the line at its inline end, haloed by the card)
  • readout (label and rolling total, start-aligned)
  • trace guide (dotted line at the hovered total)

Variants

  • 0: variant: default · grid · trace · isometric · monospace
  • 1: orientation: columns · rows
  • 2: stack: none · stacked · expanded
  • 3: references
  • 4: readout (header label and rolling total, follows the pointer)
  • 5: highlight: max · last (leads at rest)

States

  • loading (skeleton bars)
  • empty (no data for the range)
  • missing values (a hatched 8 px stub in the bar's slot, never a zero bar; tooltip and table say Not measured)
  • series hidden from the legend
  • table view
  • trace: the bar under the pointer leads, the others fade toward the card colour (never through transparency), a dotted guide marks its total, the readout rolls to it
  • highlight: the largest or latest bar leads at rest; the readout shows it
  • legend folded: entries the room cannot hold fold into “+N” (a series turned off always shows); “+N” opens the rest in place, “Less” folds them
  • legend focus: pointing at or focusing a legend entry brings its series forward while the others recede

Keyboard

  • Tab focuses the plot; ←/→ (or ↑/↓) move the tooltip point by point, including onto unmeasured points; the first press starts at an end; Home/End jump; Escape hides the tooltip
  • The table button switches to a table of every value and back
  • Legend entries: Tab reaches each; focus brings its series forward, Enter or Space turns it off and on; “+N” opens the folded entries

Motion

Bars grow out of the baseline once (500 ms; monospace none); afterwards stacking, a hidden series or new data carries every bar to its new place and size. A bar out of focus fades toward the card colour over --pui-motion-out and the readout rolls. Nothing moves under reduced motion. A resize lands at once, never travelling. In a plot narrower than about two tooltips the tooltip docks away from the reading (columns: at the top edge on the other side; rows: at the right edge in the other half) and slides across when the reading crosses the middle. Pointing at a legend entry brings its bars forward and lets the others recede.

Props

PropTypeDefaultDescription
data / xT[] / keyof T—data: Records whose fields are read by the chart series. Required. x: The category column: "month", "region".
seriesChartSeries[]—Series definitions naming the data fields, labels and formats. Required.
title / hideTitle / descriptionstring / boolean / ReactNode—title: Heading shown above the content. Required. hideTitle: Hides the title; defaults to false. Deprecated: Use showTitle={false} instead. description: Supporting text beneath the label or heading. Defaults to no supporting text.
xFormat / yFormat(v) => string—xFormat: Formats the raw horizontal-axis value for labels and tooltips. Defaults to the raw category label. yFormat: Formats the raw vertical-axis value for labels and tooltips. Defaults to compact number labels.
heightnumber | "fill"—The chart's height in px (260), or "fill" to take its container's height: columns keep as many value ticks as that height reads well with.
grid / legend / tableboolean—grid: Draws reference grid lines behind the plotted values. Defaults to true. legend: Shows labels and colour keys for the data. Defaults to true. table: Offers a table view of the same chart data. Defaults to true.
loadingboolean—Shows the loading state while data or an operation is pending. Defaults to false.
actionsReactNode—Actions displayed with the heading or toolbar. Defaults to no actions.
classNamestring—Classes on the documented visual root; no override by default.
variantBarVariant—Legacy appearance setting; omitted by default. Deprecated: Use appearance instead.
orientation"columns" | "rows"—columns: vertical bars; rows: horizontal bars (long category names).
stack"none" | "stacked" | "expanded"—Whether series are grouped, stacked or expanded to shares. Defaults to "none".
referencesChartReference[]—Reference lines shown with their labels on the plot. Defaults to an empty list.
readoutboolean—The category label and its total, large, in the header; it follows the pointer. Default on for trace.
highlight"max" | "last"—A bar that leads at rest while the others recede: the largest or the latest.
classNamesChartClassNames—Classes for the named visual parts; no overrides by default.
style / refCSSProperties / Ref<HTMLElement>—style: Inline styles on the documented visual root; no overrides by default. ref: Receives the documented native target or imperative handle; omitted by default.
emptyLabelstring—What an empty chart says, in the product's own words ("No deploys yet"). Default: "No data for this range" on a chart over time, "No data yet" on the others.
data (required)T[]—Records whose fields are read by the chart series. Required.
x (required)keyof T & string—The category column: "month", "region".
title (required)string—Heading shown above the content. Required.
showTitleboolean—Shows the title visually while keeping its accessible name; defaults to true. Takes precedence over hideTitle.
hideTitleboolean—Hides the title; defaults to false. Deprecated: Use showTitle={false} instead.
descriptionReactNode—Supporting text beneath the label or heading. Defaults to no supporting text.
appearanceBarVariant—How bars are drawn: rounded, cells, trace, isometric or monospace; defaults to default.
xFormat((value: unknown) => string)—Formats the raw horizontal-axis value for labels and tooltips. Defaults to the raw category label.
yFormat((value: number) => string)—Formats the raw vertical-axis value for labels and tooltips. Defaults to compact number labels.
gridboolean—Draws reference grid lines behind the plotted values. Defaults to true.
legendboolean—Shows labels and colour keys for the data. Defaults to true.
tableboolean—Offers a table view of the same chart data. Defaults to true.
styleCSSProperties—Inline styles on the documented visual root; no overrides by default.
refRef<HTMLElement>—Receives the documented native target or imperative handle; omitted by default.

Built from

Used in

Dependencies

d3-shape, motion

Import

import { BarChart } from "@beamline/bar-chart";

Get it

Bar chart is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Get Beamline · Connect your agent

More in Charts & data-vis

  • Sankey chart: Flows between stages as bands whose width is the amount: sources to pages to outcomes, budgets to teams; hovering or focusing a node lights its flows and…
  • Geo map: Values by country as a choropleth on the system's own world outline (no map service): classes from a sequential or diverging ramp with a legend you can…
  • Streamgraph: Stacked flows over time around a centre baseline, with silhouette, wiggle, expand (shares) and zero offsets: a legend that turns layers on and off, a…
  • Ridgeline: Distributions per group as overlapping density ridges (response time by region, order size by plan): an overlap control, median and p95 readouts per row…
  • Treemap: Nested rectangles sized by value (spend by team, then service), squarified so tiles stay close to square: labels that fit or hide, hover and focus…
  • Gantt chart: A plan as bars on a timeline: tasks grouped down the side, each bar from its start to its end with its progress, milestones as diamonds, arrows from each…
  • Activity heatmap: A calendar of daily counts, one cell per day on a sequential ramp: weeks across, weekdays down, month and weekday labels, a legend scale, hatched days…
  • Gauge: One value against a known range: a semicircle, a 270° dial or a full ring, filled or with a needle, coloured bands with their names (healthy, busy…
  • Radial chart: Progress of a few measures toward their targets as concentric rings, full or half circle, with a centre readout and a list of each ring's value, target…
  • Radar chart: A few series compared across the same five to eight dimensions as polygons on a polygon or circle grid; hover or arrow keys pick a dimension and read…
  • Scatter chart: Two measures of many items against each other, one point per item, or a bubble chart when a third measure sizes the points: groups by colour and shape…
  • Area chart: Amounts over time as filled areas: overlapping, stacked or as shares of 100%, five fills, two strokes, five curves, a range handle; gaps for missing…
  • Composed chart: Different measures on one time axis: bars, lines and areas per series, a left and a right value axis with their own formats, and reference lines.
  • Funnel chart: People or deals moving through ordered steps, each step a bar narrowing from the first: the part lost between two steps stays beside the next as a fading…
  • Waffle chart: Units of a whole as a grid of cells by category (seats used of a plan, tickets by channel): a 10×10 grid by default, hatched cells for units whose…
  • Slope chart: Change between two points in time per item, by value or by rank: labels on both sides that never collide, rising and falling told by the end marker (▲ ▼)…
  • Line chart: Values over time as lines: curves, point markers, dashed series for forecasts, reference lines for limits and targets, an optional zero baseline and a…
  • Pie chart: A few shares of a whole as a pie or donut, with spaced slices, percent labels, a centre readout and a list of every slice with value and share; hovering…
  • Sparkline: A compact trend beside its value: point along it or focus it and use ← → to read each point; nulls are gaps. TrendLine is the bare line.

Part of Beamline UI: polished, editable React components and complete screens for custom applications. Build your own style from any look; tokens, fonts, radii, motion; not only colours.