trackballInfo method

  1. @override
TrackballInfo? trackballInfo(
  1. Offset position
)
override

Implementation

@override
TrackballInfo? trackballInfo(Offset position) {
  final List<Offset> linePoints = <Offset>[points.first, points.last];
  final int nearestPointIndex = _findNearestPoints(linePoints, position);
  if (nearestPointIndex != -1) {
    final int segmentIndex = nearestPointIndex == 0
        ? currentSegmentIndex
        : currentSegmentIndex + 1;
    final int pointIndex = clampInt(segmentIndex, 0, series.dataCount - 1);
    final CartesianChartPoint<D> chartPoint = _chartPoint(pointIndex);
    return ChartTrackballInfo<T, D>(
      position: linePoints[nearestPointIndex],
      point: chartPoint,
      series: series,
      pointIndex: currentSegmentIndex,
      seriesIndex: series.index,
    );
  }
  return null;
}