Charts
Chart axes
Linear, logarithmic, time, category and time-category axes with nice ticks, calendar-aware time ticks, ranges, multiple axes, label overlap strategies, edge labels and zoom ranges.
Axes are xAxis, yAxis and any number of extra axes (each with an
id and a direction); a series picks its axes with series.xAxis /
series.yAxis, and axis.position: 'end' opposes an axis.
Every axis option below is a field of xAxis, yAxis, an axes entry or
a ChartAxis child of Chart (@salmonui/charts/chart).
Panes
panes splits the plot into rows and columns; an axis picks its pane with
axis.pane, and its series follow it:
<Chart
panes={{ rows: ['70%', '30%'] }}
axes={[{ id: 'volume', direction: 'y', pane: { row: 1 }, title: 'Volume' }]}
series={[
{ type: 'line', xField: 'date', yField: 'close' },
{ type: 'column', xField: 'date', yField: 'volume', yAxis: 'volume' },
]}
/>
Axes on the left or right take a row (pane.row), axes on the top or
bottom a column (pane.column); pane.span covers several. A size is px,
'n%' of the plot or { size }; unsized panes share the rest equally.
Axes of one side in different panes share one slot instead of stacking
outward, and each axis draws its line and title along its own pane.
Scales
scale: 'linear'(the default for numbers) uses 1-2-5 nice ticks.scale: 'time'(the default forDatevalues and ISO date strings) ticks on calendar boundaries: local midnight, the first of a month, ... in the charttimeZone.axis.interval: { unit, step }fixes the interval andaxis.formattakes a date skeleton ('yMMMd') orIntl.DateTimeFormatOptions. WithouttimeZone, server and client render in UTC.scale: 'category'(the default for strings) andscale: 'timeCategory'(dates without gaps) place one band per value;axis.labelPlacement: 'between' | 'on'puts labels between ticks or on them, andaxis.indexed: truegives every point index its own band, so repeated categories stay separate.scale: 'log'withaxis.base.
Axis scales and ranges
Open demoTime and time-category axes with calendar intervals, linear and log value axes, an indexed category axis with label placement, and axis ranges with includeZero, padding, min, max, interval and tickCount.
Line chart: Closing price, 1 series, x from Mar 2 to Mar 30. Close: 22 points, minimum 180, maximum 208.88, trending up.
| x | Close |
|---|---|
| Mar 2 | $180 |
| Mar 3 | $185 |
| Mar 4 | $189 |
| Mar 5 | $193 |
| Mar 6 | $196 |
| Mar 9 | $197 |
| Mar 10 | $197 |
| Mar 11 | $196 |
| Mar 12 | $193 |
| Mar 13 | $191 |
| Mar 16 | $188 |
| Mar 17 | $185 |
| Mar 18 | $183 |
| Mar 19 | $182 |
| Mar 20 | $182 |
| Mar 23 | $183 |
| Mar 24 | $186 |
| Mar 25 | $190 |
| Mar 26 | $195 |
| Mar 27 | $200 |
| Mar 30 | $204 |
| Mar 31 | $209 |
Line chart: Users per year, 1 series, x from 2016 to 2025. Users: 10 points, minimum 30, maximum 79,254, trending up.
| x | Users |
|---|---|
| 2016 | 30 |
| 2017 | 72 |
| 2018 | 173 |
| 2019 | 415 |
| 2020 | 995 |
| 2021 | 2,389 |
| 2022 | 5,733 |
| 2023 | 13,759 |
| 2024 | 33,023 |
| 2025 | 79,254 |
Column chart: Output per shift, 1 series, x from Mon to Tue. Output: 5 points, minimum 39, maximum 51, trending up.
| x | Output |
|---|---|
| Mon | 42 |
| Tue | 47 |
| Wed | 51 |
| Mon | 39 |
| Tue | 44 |
Ranges
axis.min, axis.max, axis.interval (numeric step), axis.tickCount,
axis.includeZero and axis.padding: 'auto' | 'none' | 'normal' | 'additional' | 'round' replace minimum, maximum, interval,
desiredIntervals, startFromZero and rangePadding.
Labels
axis.labelOverlap resolves crowded labels: 'hide' (keep every n-th),
'trim', 'wrap', 'stagger', 'rotate45' or 'rotate90', and
axis.labelAngle sets a fixed rotation. Widths come from a deterministic
text-width table, so server and client agree without measuring text.
axis.edgeLabels: 'hide' | 'shift' keeps the first and last
label inside the chart.
axis.labelPosition and axis.tickPosition ('inside' | 'outside') put
the labels and the tick marks inside or outside the plot independently,
and axis.plotOffset (px) pads both ends of the axis.
axis.ticks: false, axis.line: false, axis.hidden, axis.gridLines
and axis.minorTicks toggle the parts of an axis; axis.title
with axis.titleAngle (degrees) names it. axis.format takes a
preset ('n1', 'c0', 'p0'), a {value} template or Intl options,
axis.formatLabel(value) returns the text, and axis.renderLabel(ctx)
returns SVG text content (a string or <tspan>s) for a tick.
Formats use the same grammar and output as Data Grid column.format:
presets ('n2', 'c2', 'p1'), Intl.NumberFormatOptions /
Intl.DateTimeFormatOptions and date skeletons ('yMMMd', 'Hm'), in
the chart locale and timeZone. There is no catalog-wide
locale context, so locale is a prop; set it so the server and the
client format alike.
onAxisLabelClick({ axisId, value, text, index }, event) reports a click
on a tick label, and axis.domain(computed) adjusts the computed range.
<Chart
data={sales}
xAxis={{
labelGroups: [
{ levels: [{ from: 'Jan', to: 'Mar', label: 'Q1' }, { from: 'Apr', to: 'Jun', label: 'Q2' }] },
{ levels: [{ from: 'Jan', to: 'Jun', label: 'H1' }], border: 'brace' },
],
}}
onAxisLabelGroupClick={({ label }) => console.log(label)}
series={[{ type: 'column', xField: 'month', yField: 'north' }]}
/>
axis.labelGroups draws multi-level labels: one row per group (a column
on a vertical axis), one cell per level from a category (or value) to
another, with border: 'rectangle' | 'brace' | 'curlyBrace' | 'none' | 'noTop' | 'noTopBottom'; onAxisLabelGroupClick reports a click on a
cell.
Axis labels, formats and groups
Open demoCrowded category labels resolved by hiding, trimming, wrapping, staggering or rotating; edge labels; inside labels and ticks; label formats, functions and SVG content; multi-level label groups; label clicks and locales.
Column chart: Units by product, 1 series, x from Espresso machine to Scale with timer. Units: 8 points, minimum 120, maximum 245, trending up.
| x | Units |
|---|---|
| Espresso machine | 120 |
| Milk frother | 173 |
| Burr grinder | 226 |
| Kettle with thermometer | 139 |
| Pour-over dripper | 192 |
| Cold brew jar | 245 |
| Tamper | 158 |
| Scale with timer | 211 |
Area chart: Revenue, 1 series, x from Jan to Dec. Revenue: 12 points, minimum 1,200,000, maximum 1,763,719, trending up.
| x | Revenue |
|---|---|
| Jan | €1.2M |
| Feb | €1.4M |
| Mar | €1.6M |
| Apr | €1.7M |
| May | €1.8M |
| Jun | €1.7M |
| Jul | €1.6M |
| Aug | €1.4M |
| Sep | €1.3M |
| Oct | €1.3M |
| Nov | €1.3M |
| Dec | €1.5M |
Clicked: nothing yet
Crossing and bands
axis.crossAt: { value, axis } draws the axis line where the crossing
axis (default: the primary axis of the other direction) has value; the
labels stay at the plot edge unless axis.labelsAtCross moves them with
the line. axis.reversed inverts an axis.
axis.bands: [{ from, to, every, until, layer, label, color, crossFrom, crossTo }] shades ranges behind or over the series, repeating with
every, and crossFrom / crossTo limit a band to a segment of the
crossing axis; axis.lines draws labelled value lines.
Multiple axes, panes, crossing and bands
Open demoA chart with three value axes, a pane for one of them, grid lines and minor ticks, axis titles, value bands and lines, and a second chart whose axes cross at zero and can be reversed.
Column chart: Plant output, 3 series, x from Jan to Dec. Output: 12 points, minimum 724, maximum 1,080, trending down. Temperature: 12 points, minimum 5, maximum 23, trending up. Defects: 12 points, minimum 3, maximum 8, trending up.
| x | Output | Temperature | Defects |
|---|---|---|---|
| Jan | 900 | 5 | 3 |
| Feb | 986 | 6 | 4 |
| Mar | 1,051 | 10 | 5 |
| Apr | 1,080 | 14 | 6 |
| May | 1,064 | 19 | 7 |
| Jun | 1,008 | 22 | 8 |
| Jul | 925 | 23 | 3 |
| Aug | 837 | 22 | 4 |
| Sep | 764 | 19 | 5 |
| Oct | 724 | 14 | 6 |
| Nov | 727 | 10 | 7 |
| Dec | 773 | 6 | 8 |
Line chart: Axes crossing at zero, 1 series, x from -10 to 10. y: 21 points, minimum -7, maximum 7, trending up.
| x | y |
|---|---|
| -10 | -5 |
| -9 | -0 |
| -8 | 3 |
| -7 | 5 |
| -6 | 7 |
| -5 | 7 |
| -4 | 6 |
| -3 | 5 |
| -2 | 4 |
| -1 | 2 |
| 0 | 0 |
| 1 | -2 |
| 2 | -4 |
| 3 | -5 |
| 4 | -6 |
| 5 | -7 |
| 6 | -7 |
| 7 | -5 |
| 8 | -3 |
| 9 | 0 |
| 10 | 5 |
Zoom range
The zoom range is a controlled triad: zoomRange / defaultZoomRange /
onZoomRangeChange, keyed by axis id in data units
({ x: [start, end] }). Ticks are recomputed for the visible range.
onVisibleRangeChange({ axisId, range }) fires once per committed change of
a continuous axis (never per drag frame), the hook for loading the data of
the visible range from the application or a @salmonui/data source.
See Chart interaction.
The zoom range demo is on Chart interaction.
Every axis field is listed under ChartAxisOptions in the
API reference.
Axis scrollbar
There is no axis scrollbar, because it does not fit the Chart bundle budget and its job is already covered: a zoomed chart pans by drag, wheel and keyboard and through the zoom toolbar. To see and move the zoomed window, link a RangeSelector:
const [zoom, setZoom] = useState<ChartZoomRange>({ x: [0, 100] });
<Chart zoom zoomRange={zoom} onZoomRangeChange={(range) => setZoom(range)} /* ... */ />
<RangeSelector value={zoom.x} onValueCommit={(x) => setZoom({ x })} /* ... */ />
Run code that reacts to scrolling in onZoomRangeChange.