Numeric X axis

Are you an AI agent?

Not every X is a timestamp. A load test runs over concurrency levels, a ride over distance. Line, bar and band series plot — and stream — over plain numbers as well as time. For bars over names, see Category bars.

01 — PICK THE AXIS TYPE
axis.x.type is 'time' by default; 'numeric' maps plain numbers. It is read once, when the chart is created — remount the chart (a React key) to switch. For names on X, use 'category': see Category bars.
<ChartContainer axis={{ x: { type: 'numeric' } }}>…</ChartContainer>
02 — KEY THE POINTS BY X
Points carry x in place of time. The spacing can be irregular — the line draws at each x and the crosshair snaps to the nearest point. A point whose x doesn't fit the axis is skipped with a dev warning.
<LineSeries data={[{ x: 1, value: 120 }, { x: 16, value: 940 }, { x: 64, value: 1235 }]} />
03 — FORMAT THE X
<XAxis format> gets the number and formats the tick labels, the crosshair label and the tooltip header. crosshairMove and pointClick report it as x.
<XAxis format={(x) => `${Number(x).toFixed(1)} km`} />
04 — STREAM IT LIKE TIME
Keep the points in state and pass them to data. The diff keys on x: a point with a new, larger x is appended with its entrance animation, and .slice(-n) rolls the window while auto-scroll keeps the newest point in view. x must increase from point to point, as time does. Imperatively, appendData and keepLast do the same.
setRide((prev) => {
const last = prev[prev.length - 1];
 
return [...prev, { x: last.x + 0.2, value: 284 }].slice(-80);
});
 
<LineSeries data={ride} />
Load testconcurrency → req/s
0204060103050
5001000
Chart: line, 493×334 px, numeric X axis. X: visible -0.726027 – 65.726; data 1 – 64; step 8. The view follows the newest point. Y: 46.6447 – 1381.71. Series: - series_1 (line "Throughput"): 8 points, 8 in view, values 120 – 1235, last 1235 at 64
Live ridedistance, km → elevation, m
0.0 km2.0 km4.0 km6.0 km1.0 km3.0 km5.0 km
300350400
Chart: line, 493×334 px, numeric X axis. X: visible -0.08 – 6.89; data 0 – 6.41; step 0.16. The view follows the newest point. Y: 251.671 – 439.658. Series: - series_2 (line "Elevation"): 40 points, 40 in view, values 262 – 419, last 318 at 6.41