CxJS

NumericAxis

import { NumericAxis } from 'cx/charts'; Copied

The NumericAxis component maps numeric data along the horizontal or vertical axis of a chart. Graph components use it to calculate their position, and the axis adapts its visible range to the data being shown. The axis is also responsive—different tick configurations are selected based on available space.

This example shows four axes: primary X and Y axes with explicit ranges, and secondary inverted axes on the opposite sides.

<Svg
  style="width: 400px; height: 300px; border: 1px dashed #ddd"
  margin="60 60 60 60"
>
  <Chart
    axes={{
      x: <NumericAxis min={100} max={500} />,
      y: <NumericAxis vertical max={5000} />,
      x2: <NumericAxis secondary inverted />,
      y2: <NumericAxis vertical secondary />,
    }}
  >
    <Rectangle fill="white" margin={1} />
    <Gridlines />
    <Gridlines xAxis="x2" yAxis="y2" />
  </Chart>
</Svg>

Be careful with gridlines when using secondary axes as they may overlap.

Configuration

PropertyTypeDescription
minnumberMinimum value.
maxnumberMaximum value.
verticalbooleanSet to true for a vertical (Y) axis.
secondarybooleanSet to true to position the axis on the opposite side (right for vertical, top for horizontal).
invertedbooleanSet to true to invert the axis direction.
snapToTicksnumberRange alignment: 0 = lowest ticks, 1 = medium ticks (default), 2 = major ticks.
normalizedbooleanSet to true to normalize the input range (0-1).
formatstringValue format for labels. Default is "n".
labelDivisornumberDivide values by this number before rendering labels. Default is 1.
deadZonenumberSize of a zone reserved for labels at both ends of the axis.
upperDeadZonenumberSize of a zone reserved for labels near the upper end of the axis.
lowerDeadZonenumberSize of a zone reserved for labels near the lower end of the axis.
minLabelTickSizenumberMinimum value increment between labels. Set to 1 for integer axes to avoid duplicate labels.