useChartHeight

Returns the height of the chart in pixels.

If you are using chart with hardcoded height props, then the height returned will be the same as the height prop on the main chart element.

If you are using a chart with a ResponsiveContainer, the height will be the size of the chart as the ResponsiveContainer has decided it would be.

If the chart has any axes or legend, the height will be the size of the chart including the axes and legend. Meaning: adding axes and legend will not change the height.

The dimensions do not scale, meaning as user zoom in and out, the height number will not change as the chart gets visually larger or smaller.

Returns undefined if used outside a chart context.

Return value

number | undefined

The height of the chart in pixels, or undefined if not in a chart context.