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) - useonBubbleHover - Stacked area charts (
StackedAreaChartWidget) - Step line charts (
StepLineChartWidget) - Spline charts (
SplineChartWidget)
Parameters:
point- The hovered data point, or null if mouse exiteddatasetIndex- The dataset index, or null if mouse exitedpointIndex- 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:
ChartPointCallbackfor tap events (all platforms)onBubbleHoverfor bubble chart-specific hover handlingChartInteractionConstantsfor interaction configuration
Implementation
typedef ChartPointHoverCallback =
void Function(ChartDataPoint? point, int? datasetIndex, int? pointIndex);