BarChart
Compare series and read the change behind them, with the axes, legend and tooltip already wired.
@luc/ui/chartsWhat it shows
Compare a measured value across named categories, or show a ranked category list without inventing a time sequence.
Live preview
Magnitude by category in millions; five bars, one series, no stacking.
<BarChart
data={[
{ quarter: "Q1", revenue: 42.6 },
{ quarter: "Q2", revenue: 46.1 },
{ quarter: "Q3", revenue: 51.8 },
{ quarter: "Q4", revenue: 49.4 },
{ quarter: "Q1 ", revenue: 55.2 },
]}
xKey="quarter"
axes={[{ id: "primary", format: { kind: "decimal", decimals: 1, suffix: "m" } }]}
series={[{ key: "revenue", label: "Revenue", type: "bar", tone: "accent", axis: "primary" }]}
height={320}
ariaLabel="Revenue by quarter"
/>Controls
Height
A chart measures its container, so it always needs a definite height.
State
The surface the chart is in — loading, empty and error are drawn by the component.
Accessible name
A drawing is not readable by a screen reader, so it needs a name that states what it shows.
The same fixture as the live preview above; the controls change how it is drawn, not what it measures.
Code
import { BarChart } from "@luc/ui/charts";
<BarChart
data={[
{ quarter: "Q1", revenue: 42.6 },
{ quarter: "Q2", revenue: 46.1 },
{ quarter: "Q3", revenue: 51.8 },
{ quarter: "Q4", revenue: 49.4 },
{ quarter: "Q1 ", revenue: 55.2 },
]}
xKey="quarter"
axes={[{ id: "primary", format: { kind: "decimal", decimals: 1, suffix: "m" } }]}
series={[{ key: "revenue", label: "Revenue", type: "bar", tone: "accent", axis: "primary" }]}
height={320}
ariaLabel="Revenue by quarter"
state="ready"
/>Not controllable here
series / rows— The numbers are the caller's; the fixture above is the example.
Copy for an AI agentA specification an agent can act on: the import, the setup, the chosen props, the data contract and the accessibility expectation.
Implement `BarChart` from Luc UI. It is: Compare series and read the change behind them, with the axes, legend and tooltip already wired.
Import it with: import { BarChart } from "@luc/ui/charts";
Requires: react ^19.0.0; react-dom ^19.0.0; react-hook-form ^7.0.0 (optional, for @luc/ui/forms/react-hook-form); tailwindcss ^4.0.0; node >= 22 (repository tools). Import the stylesheet once at the app root and wrap the tree in `LucProvider`. Both come from the package that publishes @luc.
Chosen configuration: `height={320}`, `state="ready"`, `ariaLabel="Revenue by quarter"`.
Accessibility: keep the component's own semantics. Do not re-implement its ARIA wiring, do not add roles it does not declare, and make sure every interactive element is reachable and operable from the keyboard with a visible focus state.
Styling: use Luc UI design tokens and the component's own props. Do not restyle with raw colour literals and do not override the component's internal structure with page CSS.
Motion: respect `prefers-reduced-motion`. The component already does, so do not disable it.
Reproduce this state:
```tsx
<BarChart
data={[
{ quarter: "Q1", revenue: 42.6 },
{ quarter: "Q2", revenue: 46.1 },
{ quarter: "Q3", revenue: 51.8 },
{ quarter: "Q4", revenue: 49.4 },
{ quarter: "Q1 ", revenue: 55.2 },
]}
xKey="quarter"
axes={[{ id: "primary", format: { kind: "decimal", decimals: 1, suffix: "m" } }]}
series={[{ key: "revenue", label: "Revenue", type: "bar", tone: "accent", axis: "primary" }]}
height={320}
ariaLabel="Revenue by quarter"
state="ready"
/>
```Usage
The values are prepared by the caller: this component draws the points it is given and computes no statistic of its own, so units, scaling and any summary have to be settled before the data reaches it.
It is drawn by the ECharts engine.
Worked examples with real data are on the family overview: General
import { BarChart } from "@luc/ui/charts";<BarChart
data={[
{ quarter: "Q1", revenue: 42.6 },
{ quarter: "Q2", revenue: 46.1 },
{ quarter: "Q3", revenue: 51.8 },
{ quarter: "Q4", revenue: 49.4 },
{ quarter: "Q1 ", revenue: 55.2 },
]}
xKey="quarter"
axes={[{ id: "primary", format: { kind: "decimal", decimals: 1, suffix: "m" } }]}
series={[{ key: "revenue", label: "Revenue", type: "bar", tone: "accent", axis: "primary" }]}
height={320}
ariaLabel="Revenue by quarter"
/>Data contract
`data` rows need a categorical `xKey` and one or more numeric `series.key` fields. The caller supplies the ordering; the chart does not sort or aggregate rows.
Important configuration
Use `orientation` for long labels, `series[].stack`/`stackMode` for composition, and `valueLabels` only on sparse bars where the exact number matters.
Guidelines
When not to use
Do not use a bar chart for a dense continuous series; a line chart preserves the order and avoids a wall of bars.
Configuration
| Export | Kind | Signature |
|---|---|---|
BarChart | 33 documented props | <TRow extends object = Record<string, unknown>>({ family, state, height, className, visibleSeries, ariaLabel, ariaDescription, onReady, onEvent, ...spec }: CartesianChartProps<TRow>) => import("@type… |
BarChart props
Type: CartesianChartProps<TRow>
Values the compiler reads from the declaration.
| Prop | Type | Default | Notes |
|---|---|---|---|
animation? | ChartAnimationPreset | undefined | — | Animation budget. Defaults to `standard`. |
annotations? | AnnotationSpec | undefined | — | |
ariaDescription? | string | undefined | — | |
ariaLabel? | string | undefined | — | |
axes? | readonly AxisSpec[] | undefined | — | Extra axes beyond the primary one. |
className? | string | undefined | — | |
data? | readonly TRow[] | undefined | — | |
description? | string | undefined | — | |
engine? | ChartEngine | undefined | — | |
extendOption? | ((option: unknown) => void) | undefined | — | Advanced: mutate the assembled engine option. Clearly not the normal path. |
family? | ChartFamily | undefined | — | Override the family the wrapper defaults to. Advanced. |
height? | string | number | undefined | — | |
id? | string | undefined | — | |
interaction? | ChartInteractionSpec | undefined | — | |
legend? | boolean | undefined | — | |
onEvent? | ((event: EChartEvent) => void) | undefined | — | |
onReady? | ((chart: EChartsInstance) => void) | undefined | — | |
orientation? | "horizontal" | "vertical" | undefined | — | Bar family only: which way the bars grow. Defaults to `vertical`. |
pointCount? | number | undefined | — | The number of plotted points, when the caller already knows it. Used only to *reduce* animation for a large series; it never changes what is drawn. |
points? | Readonly<Record<string, ChartPointMeta>> | undefined | — | Per-point display metadata, keyed by the x value's canonical string form. A generic hook for a caller whose x values carry a better label or extra hover context than the axis can … |
ranges? | ChartRangeSpec | undefined | — | |
renderer? | ChartRenderer | undefined | — | Drawing layer. Defaults to `canvas`. Set `svg` when the chart is going to be captured rather than read: vector output survives PDF export and scales without a density choice. Igno… |
scale? | { allowed?: readonly YScaleMode[]; default?: YScaleMode; mode?: YScaleMode; } | undefined | — | Scale capability and current mode. `allowed` is what the *product* declares it may offer (a signed drawdown is linear-only); `default` is what it opens on; `mode` is what the read… |
series | readonly SeriesSpec[] | — | |
state? | ChartState | undefined | — | |
syncGroup? | string | undefined | — | |
title? | string | undefined | — | |
tooltip? | ChartTooltipSpec | undefined | — | |
unit? | string | undefined | — | |
universalTransition? | boolean | undefined | — | Morph the *same data* between two representations (a histogram ↔ a ranked bar, a stacked ↔ a grouped bar). Opt-in, because a morph between charts that do not share a data identity… |
visibleSeries? | readonly string[] | undefined | — | |
x? | AxisSpec | undefined | — | |
xKey? | string | undefined | — | Field that supplies the x value for tabular data. |
Accessibility
A chart is a picture of data, so it needs a name that states what it shows, and the numbers must exist as text somewhere on the page — in a table or a written summary — because a drawing is not readable by a screen reader and cannot be copied.
What happens on the server, and when hydration changes it.
Family
General
The shapes every product needs, on the declarative ChartSpec path.
Related