Skip to content

Callbacks and payloads ​

Optional callback props reported by both chart entry points, and the payload each one receives. See Interaction for how focus, filtering, and pointer events behave, and Chart props for the controlled props that pair with them.

This page is generated from the type declarations in the library source, so it documents exactly what the shipped .d.ts and your editor hovers do.

Callbacks ​

Every callback is optional; only the ones you pass are wired up.

From the ChartCallbacks interface. Property anchors are stable: link to any entry as #callbacks.propertyName.

onChartClick ​

The plot area was clicked.

onSliceClick ​

A pie-type slice was clicked; fires only on click (unlike hover-driven onFocus), so it can anchor selection.

onSeriesClick ​

A cartesian series shape (bar, marker, label, line/area path) was clicked. Independent of focusOnClick; fires only on click, so it can anchor selection.

onChartMouseEnter ​

The pointer entered the plot area.

onChartMouseMove ​

The pointer moved within the plot area.

onChartMouseLeave ​

The pointer left the plot area.

onTitleClick ​

The chart title was clicked (see title.link/title.linkDisabled).

  • Type: () => void
  • Required: no

onFocus ​

The focused series/category/value axis — via pointer over/click on the plot or the legend, per the focusOnHover/focusOnClick config.

  • Type: (focus: ChartFocus) => void
  • Required: no
  • See: ChartFocus

onSeriesFilter ​

A legend click toggled a series in or out of the filtered set (requires legend.filterOnClick).

onSeriesLayoutBoundsChange ​

The plot area was re-laid-out; reports its new bounds.

  • Type: (bounds: Bounds) => void
  • Required: no

ChartEventPayload ​

Received by the four plot-area pointer callbacks.

From the ChartEventPayload interface. Property anchors are stable: link to any entry as #chartEventPayload.propertyName.

chartX ​

Pointer x relative to the plot area, in plot pixels.

  • Type: number
  • Required: yes

chartY ​

Pointer y relative to the plot area, in plot pixels.

  • Type: number
  • Required: yes

categoryPosition ​

Pointer position along the category axis, in plot pixels.

  • Type: number
  • Required: yes

valuePosition ​

Pointer position along the value axis, in plot pixels.

  • Type: number
  • Required: yes

categoryFraction ​

Pointer position along the category axis as a 0–1 fraction of the plot.

  • Type: number
  • Required: yes

valueFraction ​

Pointer position along the value axis as a 0–1 fraction of the plot.

  • Type: number
  • Required: yes

categoryIndex ​

Index of the category nearest the pointer, -1 when none.

  • Type: number
  • Required: yes

ChartFocus ​

Received by onFocus — the whole focus state, not just what changed.

From the ChartFocus interface. Property anchors are stable: link to any entry as #chartFocus.propertyName.

focusedValueAxisId ​

Id of the focused value axis, or null when no axis is focused.

  • Type: string | null
  • Required: yes

focusedSeriesId ​

Id of the focused series, or null when no series is focused.

  • Type: string | null
  • Required: yes

focusedCategoryIndex ​

Index of the focused category, -1 when no category is focused.

  • Type: number
  • Required: yes

ChartSeriesFilter ​

Received by onSeriesFilter — the whole filter map, not just what changed.

From the ChartSeriesFilter interface. Property anchors are stable: link to any entry as #chartSeriesFilter.propertyName.

filteredSeriesIds ​

Map of series id → true for every series currently filtered out.

  • Type: Record<string, boolean>
  • Required: yes

ChartSliceClickPayload ​

Received by onSliceClick.

From the ChartSliceClickPayload interface. Property anchors are stable: link to any entry as #chartSliceClickPayload.propertyName.

seriesId ​

Id of the clicked slice's series (the leader for follower series).

  • Type: string
  • Required: yes

ChartSeriesClickPayload ​

Received by onSeriesClick.

From the ChartSeriesClickPayload interface. Property anchors are stable: link to any entry as #chartSeriesClickPayload.propertyName.

seriesId ​

Id of the clicked shape's series (the leader for follower series).

  • Type: string
  • Required: yes

categoryIndex ​

Index of the clicked bar/marker/label's category; -1 for a whole-series shape (line/area path).

  • Type: number
  • Required: yes

nearestCategoryIndex ​

Index of the category nearest the pointer, as onChartClick reports it; -1 when none.

  • Type: number
  • Required: yes

Released under the MIT License.