useYAxisScale

Returns a function to convert data values to pixel coordinates for a YAxis.

This is useful for positioning annotations, custom shapes, or other elements at specific data points on the chart.

This hook must be used within a chart context (inside a LineChart, BarChart, etc.). Returns undefined if used outside a chart context, or if the axes don't exist.

Available since Recharts 3.8

Return value

ScaleFunction | undefined

A scale function that maps data values to pixel coordinates, or undefined.

Props

  • yAxisIdnumber | stringoptional

    The yAxisId of the YAxis. Defaults to 0 if not provided.

    默认值:"defaultAxisId"