Skip to main content
YAxis
@coinbase/cds-web@9.28.0
A vertical axis component for CartesianChart. Displays tick marks, labels, gridlines, and supports custom formatting, positioning, and data domains.
import { YAxis } from '@coinbase/cds-web/visualizations/chart'
Peer dependencies
  • framer-motion: ^10.18.0
Related components

Basics​

The YAxis component provides a vertical axis for charts with automatic tick generation and labeling.

Loading...

Axis Config​

Properties related to the scale of an axis are set on the Chart component. This includes scaleType, domain, domainLimit, range, data, and categoryPadding.

Scale Type​

YAxis supports linear (default) and log scale types. Both linear and log are numeric scales.

Loading...

Domain​

An axis's domain is the range of values that the axis will display. You can pass in either an object (AxisBounds) with min and max properties (both optional), or a function that receives initial AxisBounds and returns an adjusted AxisBounds.

Loading...

Domain Limit​

You can set the domain limit to nice (default for YAxis) or strict. nice will round the domain to human-friendly values, while strict will use the exact min/max values from the data. See d3-scale for more details.

Range​

An axis's range is the range of values that the axis will display in pixels. This is most useful for adjusting the sizing of the data inside of the chart's drawing area.

You can pass in either an object (AxisBounds) with min and max properties (both optional), or a function that receives initial AxisBounds and returns an adjusted AxisBounds.

Loading...

Axis Props​

Properties related to the visual appearance of the YAxis are set on the component itself. This includes position, showGrid, showLine, showTickMarks, size, tickInterval, ticks, tickLabelFormatter, tickLabelOverflow, and tickMarkSize.

Position​

You can set the position of an axis to left or right (default).

Loading...

When layout="horizontal", CartesianChart supports only one y-axis configuration.

Grid​

You can show grid lines at each tick position using the showGrid prop.

Loading...

You can also customize the grid lines using the GridLineComponent prop.

Loading...

Line​

You can show the axis line using the showLine prop.

Loading...

You can also customize the axis line using the classNames and styles props.

Loading...

Size​

The size prop sets the size of the axis in pixels. The default is 44 for YAxis, but can be adjusted to fit the size of your data.

Loading...

Ticks​

You can use the ticks, requestedTickCount (default for YAxis), and tickInterval props to control the number and placement of ticks on the YAxis.

ticks accepts an array of numbers, which corresponds to the values of that axis that you would like to display ticks for.

Loading...

Using requestedTickCount will use D3's ticks function to determine the number and placement of ticks. Note that this count is not guaranteed to be respected.

This is the default behavior for YAxis, and defaults to 5.

Loading...

tickInterval, which accepts a number for the gap between ticks in pixels, will measure the available space and try to create evenly spaced ticks. It will always include the first and last values of the domain.

Loading...

Tick Marks​

You can show tick marks on the axis using the showTickMarks prop. You can also customize the tick mark size using the tickMarkSize prop.

Loading...

Tick Labels​

You can customize the tick labels using the tickLabelFormatter prop.

Loading...

Tick Label Overflow​

Use tickLabelOverflow to control how tick labels behave at the chart edges.

Loading...

Label​

You can add a label to the axis using the label prop.

Loading...

Custom Tick Labels​

You can create custom tick label components using the TickLabelComponent prop for advanced styling and positioning that works cross-platform.

Loading...

Customization​

Multiple Y Axes​

Loading...

Is this page useful?

Coinbase Design is an open-source, adaptable system of guidelines, components, and tools that aid the best practices of user interface design for crypto products.