Skip to main content

Variable: useOffset

@arolariu/components


@arolariu/components / useOffset

Variable: useOffset

useOffset: () => ChartOffset

Defined in: components/ui/chart.tsx:628

Returns the offset of the chart in pixels.

Offset defines the blank space between the chart and the plot area. This blank space is occupied by supporting elements like axes, legends, and brushes.

The offset includes:

  • Margins
  • Width and height of the axes
  • Width and height of the legend
  • Brush height

If you are interested in the margin alone, use useMargin instead.

The offset is independent of charts position on the page, meaning it does not change as the chart is scrolled or resized.

It is also independent of the scale and zoom, meaning that as the user zooms in and out, the numbers will not change as the chart gets visually larger or smaller.

This hook must be used within a chart context (inside a <LineChart>, <BarChart>, etc.). This hook returns undefined if used outside a chart context.

Returns

ChartOffset

Offset of the chart in pixels, or undefined if used outside a chart context.

Since

3.1

// was this page useful?