Category bars

Are you an AI agent?

Revenue by region, votes by option, latency by endpoint: a bar chart over names. Put a category axis on X, group a series' layers side by side, stack them or show their shares, label the values, and keep the bars readable while categories come and go. For plain numbers on X, see Numeric X axis.

01 — PUT NAMES ON X
axis.x.type: 'category' maps names. Each category gets one band, in the order the series first name it, and the bars fill their band. axis.x.padding sets the gap between bands (inner) and at the ends (outer), as fractions of a step. Drag and wheel are off on a category axis — set axis.x.panZoom to change that. The type is read once, when the chart is created — remount the chart (a React key) to switch.
<ChartContainer axis={{ x: { type: 'category', padding: { inner: 0.3, outer: 0.2 } } }}>
<BarSeries data={[{ x: 'Europe', value: 42 }, { x: 'Asia', value: 35 }]} />
</ChartContainer>
02 — GROUP THE LAYERS
On a category axis, one BarSeries with several layers draws them side by side in each band, in layer order, colored from the theme palette. That is the default with stacking: 'off'. Two separate BarSeries still overlap.
<ChartContainer axis={{ x: { type: 'category' } }}>
<BarSeries
data={[
{ label: '2024', data: [{ x: 'Europe', value: 46 }, { x: 'Asia', value: 41 }] },
{ label: '2025', data: [{ x: 'Europe', value: 49 }, { x: 'Asia', value: 47 }] },
]}
/>
</ChartContainer>
03 — FIX THE ORDER
axis.x.categories puts the listed names first, in list order — also a name no series has data for yet, as an empty band. Names not in the list follow in first-seen order.
<ChartContainer axis={{ x: { type: 'category', categories: ['Asia', 'Europe', 'Americas'] } }}>
04 — LABEL THE VALUES
valueLabels writes each value just past the bar's end. A label wider than its bar is skipped. The text follows <YAxis format>; pass { format } to set it apart. The color is theme.bar.labelColor.
<BarSeries data={layers} options={{ valueLabels: { format: (v) => `$${v}M` } }} />
05 — STACK, OR SHOW SHARES
stacking: 'normal' draws one column per band, with the column total as its label. 'percent' draws each layer's share of the column, so every column fills 100%; it has no labels.
<BarSeries data={layers} options={{ stacking: 'percent' }} />
06 — NEGATIVE VALUES
A negative bar grows down from zero, rounds its lower end and hangs its label below. In a 100% stack a column splits by its absolute sum: +3 and −1 give +75% up and −25% down.
<BarSeries data={[{ label: '2025', data: [{ x: 'Asia', value: 6 }, { x: 'Americas', value: -6 }] }]} />
07 — CATEGORIES THAT COME AND GO
Pass the new array. A category that leaves fades out in its own band, then the bands close up and the later bars slide over; one that comes back slides the others aside and fades in. Values that change ease to their new height, and the Y axis eases with them. A category axis doesn't scroll: the bands refit so every category stays in view. Hovering a band shades it and lists every layer in the tooltip. Imperatively, pass the whole array to setSeriesData; updateData replaces only the layer's last point.
const regions = away ? REGIONS.filter((r) => r !== 'Americas') : REGIONS;
 
<BarSeries data={toLayers(REVENUE, regions)} />
Grouped$M per year, Asia first
AsiaEuropeAmericasAfricaOceania
050
Chart: bar, 493×142 px, category X axis. X: visible -0.55 – 4.55; data Asia – Oceania; step 1. The view follows the newest point. Y: -7.42424 – 56.4242. Series: - series_1 (bar "2023"): 3 layers, 15 points, 5 in view, values 0 – 49, last 8 at Oceania
100% stackedshare of each region's revenue
EuropeAsiaAmericasAfricaOceania
0%100%
Chart: bar, 493×142 px, category X axis. X: visible -0.55 – 4.55; data Europe – Oceania; step 1. The view follows the newest point. Y: -15.1515 – 115.152. Series: - series_2 (bar "2023"): 3 layers, 15 points, 5 in view, values 0 – 100, last 8 at Oceania
Negative valuespts vs. prior year
EuropeAsiaAmericasAfricaOceania
0
Chart: bar, 493×142 px, category X axis. X: visible -0.55 – 4.55; data Europe – Oceania; step 1. The view follows the newest point. Y: -7.81818 – 7.81818. Series: - series_3 (bar "2024"): 2 layers, 10 points, 5 in view, values -6 – 6, last -1 at Oceania
LiveAmericas comes and goes
EuropeAsiaAmericasAfricaOceania
050
Chart: bar, 493×142 px, category X axis. X: visible -0.55 – 4.55; data Europe – Oceania; step 1. The view follows the newest point. Y: -7.42424 – 56.4242. Series: - series_4 (bar "2023"): 3 layers, 15 points, 5 in view, values 0 – 49, last 8 at Oceania