tooltipInfo method

  1. @override
TooltipInfo? tooltipInfo({
  1. Offset? position,
  2. int? pointIndex,
})
override

Implementation

@override
TooltipInfo? tooltipInfo({Offset? position, int? pointIndex}) {
  final int nearestPointIndex =
      position == null ? 0 : _nearestPointIndex(points, position);
  if (nearestPointIndex != -1) {
    pointIndex ??= (position == null || nearestPointIndex == 0
        ? currentSegmentIndex
        : currentSegmentIndex + 1);
    final CartesianChartPoint<D> chartPoint = _chartPoint(pointIndex);
    final ChartMarker marker = series.markerAt(pointIndex);
    final double markerHeight =
        series.markerSettings.isVisible ? marker.height / 2 : 0;
    final Offset preferredPos = points[nearestPointIndex];
    return ChartTooltipInfo<T, D>(
      primaryPosition:
          series.localToGlobal(preferredPos.translate(0, -markerHeight)),
      secondaryPosition:
          series.localToGlobal(preferredPos.translate(0, markerHeight)),
      text: series.tooltipText(chartPoint),
      header: series.name,
      data: series.dataSource![pointIndex],
      point: chartPoint,
      series: series.widget,
      renderer: series,
      seriesIndex: series.index,
      segmentIndex: currentSegmentIndex,
      pointIndex: pointIndex,
      markerColors: <Color?>[fillPaint.color],
      markerType: marker.type,
    );
  }
  return null;
}