useXAxisDomain

Returns the calculated domain of an X-axis.

The domain can be numerical: [min, max], or categorical: ['a', 'b', 'c'].

The type of the domain is defined by the type prop of the XAxis.

The values of the domain are calculated based on the data and the dataKey of the axis.

If the chart has a Brush, the domain will be filtered to the brushed indexes if the hook is used outside a Brush context, and the full domain will be returned if the hook is used inside a Brush context.

Return value

CategoricalDomain | NumberDomain | undefined

The domain of the X-axis, or undefined if it cannot be calculated or if used outside a chart context.

Props

  • xAxisIdnumber | stringoptional

    The xAxisId of the X-axis. Defaults to 0 if not provided.

    DEFAULT: "defaultAxisId"