tooltipInfo method
TooltipInfo?
tooltipInfo(
{ - Offset? position,
- int? pointIndex,
})
override
Implementation
@override
TooltipInfo? tooltipInfo({Offset? position, int? pointIndex}) {
if (points.isEmpty) {
return null;
}
pointDistance = series.markerSettings.width / 2;
pointIndex ??= _findNearestChartPointIndex(points, position!);
if (pointIndex != -1) {
final Offset position = points[pointIndex];
if (position.isNaN) {
return null;
}
final int actualPointIndex = _drawIndexes[pointIndex];
final CartesianChartPoint<D> chartPoint = _chartPoint(actualPointIndex);
final num x = chartPoint.xValue!;
final num y = series.topValues[actualPointIndex];
final double dx = series.pointToPixelX(x, y);
final double dy = series.pointToPixelY(x, y);
final ChartMarker marker = series.markerAt(pointIndex);
final double markerHeight =
series.markerSettings.isVisible ? marker.height / 2 : 0;
final Offset preferredPos = Offset(dx, dy);
return ChartTooltipInfo<T, D>(
primaryPosition:
series.localToGlobal(preferredPos.translate(0, -markerHeight)),
secondaryPosition:
series.localToGlobal(preferredPos.translate(0, markerHeight)),
text: series.tooltipText(chartPoint),
header: series.parent!.tooltipBehavior!.shared
? series.tooltipHeaderText(chartPoint)
: series.name,
data: series.dataSource![pointIndex],
point: chartPoint,
series: series.widget,
renderer: series,
seriesIndex: series.index,
segmentIndex: currentSegmentIndex,
pointIndex: actualPointIndex,
markerColors: <Color?>[fillPaint.color],
markerType: marker.type,
);
}
return null;
}