Skip to main content
Hooks for accessing axis configuration, domains, and ticks.

useXAxis

Returns the configuration and scale information for an X-axis.
AxisId
default:"0"
The ID of the X-axis. Defaults to 0 if not provided.
BaseAxisWithScale | undefined
The axis configuration with scale, or undefined if the axis doesn’t exist or if used outside a chart context.

useYAxis

Returns the configuration and scale information for a Y-axis.
AxisId
default:"0"
The ID of the Y-axis. Defaults to 0 if not provided.
BaseAxisWithScale | undefined
The axis configuration with scale, or undefined if the axis doesn’t exist or if used outside a chart context.

useXAxisDomain

Returns the calculated domain of an X-axis. The domain can be numerical [min, max] or categorical ['a', 'b', 'c']. The type is defined by the type prop of the XAxis.
AxisId
default:"0"
The ID of the X-axis. Defaults to 0 if not provided.
NumberDomain | CategoricalDomain | undefined
The domain of the X-axis, or undefined if it cannot be calculated or if used outside a chart context.
Since: 3.2

Brush interaction

If the chart has a Brush:
  • Outside Brush context: returns the filtered domain (brushed indexes only)
  • Inside Brush context: returns the full domain

useYAxisDomain

Returns the calculated domain of a Y-axis. The domain can be numerical [min, max] or categorical ['a', 'b', 'c']. The type is defined by the type prop of the YAxis.
AxisId
default:"0"
The ID of the Y-axis. Defaults to 0 if not provided.
NumberDomain | CategoricalDomain | undefined
The domain of the Y-axis, or undefined if it cannot be calculated or if used outside a chart context.
Since: 3.2

useXAxisTicks

Returns the ticks of an X-axis. The ticks are the same as the ones rendered by the XAxis component.
AxisId
default:"0"
The ID of the X-axis. Defaults to 0 if not provided.
ReadonlyArray<TickItem> | undefined
Array of ticks, or undefined if the axis doesn’t exist or hasn’t been calculated yet.
Since: 3.8

useYAxisTicks

Returns the ticks of a Y-axis. The ticks are the same as the ones rendered by the YAxis component.
AxisId
default:"0"
The ID of the Y-axis. Defaults to 0 if not provided.
ReadonlyArray<TickItem> | undefined
Array of ticks, or undefined if the axis doesn’t exist or hasn’t been calculated yet.
Since: 3.8

Types

TickItem

NumberDomain

CategoricalDomain