ChartTapCallback typedef

ChartTapCallback = void Function(Offset position)

Callback for chart background/empty area tap interactions.

Invoked when a user taps on an empty area of the chart (not on any data element). Useful for deselecting items, closing menus, or resetting chart state.

Supported Charts:

  • All chart types support this callback

Parameters:

  • position - The global tap position where the user tapped

Usage Notes:

  • This callback is nullable - if null, background taps are ignored
  • Only fires when tapping on empty chart area (not on data points, bars, segments, etc.)
  • Useful for implementing "tap to deselect" or "tap to close menu" behavior

Example

onChartTap: (position) {
  // Deselect all items
  setState(() {
    selectedItem = null;
  });
  // Close any open menus
  ChartContextMenuHelper.hide();
}

See also:

Implementation

typedef ChartTapCallback = void Function(Offset position);