tooltipInfo method

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

Implementation

@override
TooltipInfo? tooltipInfo({Offset? position, int? pointIndex}) {
  if (segmentRect == null) {
    return null;
  }

  pointIndex ??= currentSegmentIndex;
  final CartesianChartPoint<D> chartPoint = _chartPoint();
  Offset primaryPos;
  Offset secondaryPos;
  if (points.isNotEmpty) {
    primaryPos = series.localToGlobal(points[0]);
    secondaryPos = primaryPos;
  } else {
    final Rect outerRect = segmentRect!.outerRect;
    primaryPos = series.localToGlobal(outerRect.topCenter);
    secondaryPos = series.localToGlobal(outerRect.bottomCenter);
  }
  return ChartTooltipInfo<T, D>(
    primaryPosition: primaryPos,
    secondaryPosition: secondaryPos,
    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: pointIndex,
    hasMultipleYValues: true,
    markerColors: <Color?>[series.paletteColor],
    markerType: series.markerAt(pointIndex).type,
  );
}