import {Chart, ChartAxis, ChartGrid, bar} from '@astryxdesign/charts';
<Chart
data={monthlyRevenue}
xKey="month"
series={[bar('revenue')]}
grid={<ChartGrid horizontal />}
axes={
<>
<ChartAxis position="bottom" />
<ChartAxis position="left" tickFormat={value => String(value)} />
</>
}
/>;Chart Axis
ChartAxis renders tick labels and optional edge and tick lines from the scales owned by a parent Chart. Use it in the Chart axes slot for physical top, right, bottom, or left plot edges.
Authored source examples
Source examples recorded in the documentation for this entry.
<ChartAxis
position="bottom"
maxTicks={8}
truncate={12}
showTicks
/>;Usage
ChartAxis renders tick labels and optional edge and tick lines from the scales owned by a parent Chart. Use it in the Chart axes slot for physical top, right, bottom, or left plot edges.
- Use ChartAxis inside Chart so its labels, ticks, and edge line share the same scales and plot dimensions as the marks.
- Use tickFormat for product-specific units or locale formatting, and maxTicks or truncate when dense category labels need a bounded presentation.
- Use axis labels or a pointer tooltip as the only way to obtain important values. Give Chart an accessible name and preserve an equivalent data view or summary.
- Hide the edge line while showing tick marks. showTicks intentionally keeps the line visible so each mark has a grounded edge.
Typed props
| Prop | Type and behavior |
|---|---|
position | 'top' | 'right' | 'bottom' | 'left' · requiredPhysical plot edge on which to render the axis. |
tickCount | number · default 5Approximate continuous-scale tick count. d3 chooses the final values. |
maxTicks | numberMaximum displayed label count. Labels are evenly skipped when the generated set is larger. |
tickFormat | (value: unknown) => stringFormats each retained tick. When omitted, continuous scales use d3 formatting and band scales use their category strings. |
truncate | numberMaximum content characters retained before an ellipsis is appended. User-perceived characters remain intact. |
animated | boolean · default trueWhether tick position and visibility changes use the built-in transition. |
showAxisLine | boolean · default true for bottom; false for top, right, and leftWhether to draw the edge line. Tick marks force the line on so they remain grounded. |
showTicks | boolean · default falseWhether to draw an outward mark at each retained tick. |
Anatomy
Line along the selected plot edge. It is shown by default only on the bottom edge and whenever tick marks are shown.
Short lines extending outward from each retained tick position.
Formatted scale values or categories positioned outside the selected plot edge.
Accessibility
Chart owns the accessible image name and supported small-data table. Tick labels supplement that chart-level alternative rather than replacing it.
Truncation keeps emoji, joined emoji sequences, flags, and combining marks intact before appending the ellipsis.