ChartPointHoverCallback typedef

ChartPointHoverCallback = void Function(ChartDataPoint? point, int? datasetIndex, int? pointIndex)

Callback for mouse hover events on chart points.

Invoked when the mouse enters or exits a point area in point-based charts. When the mouse exits, all parameters will be null.

Supported Charts:

  • Line charts (LineChartWidget)
  • Area charts (AreaChartWidget)
  • Scatter charts (ScatterChartWidget)
  • Bubble charts (BubbleChartWidget) - use onBubbleHover
  • Stacked area charts (StackedAreaChartWidget)
  • Step line charts (StepLineChartWidget)
  • Spline charts (SplineChartWidget)

Parameters:

  • point - The hovered data point, or null if mouse exited
  • datasetIndex - The dataset index, or null if mouse exited
  • pointIndex - The point index, or null if mouse exited

Usage Notes:

  • This callback is nullable - if null, hover interactions are disabled
  • Platform Support: Desktop and web only (mouse hover not available on mobile)
  • The hover detection uses ChartInteractionConstants.hoverRadius for hit detection
  • All parameters are nullable - check for null to detect mouse exit

Example

onPointHover: (point, datasetIndex, pointIndex) {
  if (point != null) {
    showTooltip('Value: ${point.y}');
  } else {
    hideTooltip();
  }
}

See also:

  • ChartPointCallback for tap events (all platforms)
  • onBubbleHover for bubble chart-specific hover handling
  • ChartInteractionConstants for interaction configuration

Implementation

typedef ChartPointHoverCallback =
    void Function(ChartDataPoint? point, int? datasetIndex, int? pointIndex);