showByIndex method

void showByIndex(
  1. int pointIndex
)

Displays the crosshair at the specified point index.

pointIndex - index of point at which the crosshair needs to be shown.

Implementation

void showByIndex(int pointIndex) {
  final SfCartesianChartState chartState = _chartState!;
  final CrosshairBehaviorRenderer crosshairBehaviorRenderer =
      chartState._crosshairBehaviorRenderer;
  if (_validIndex(
      pointIndex, 0, crosshairBehaviorRenderer._crosshairPainter!.chart)) {
    if (crosshairBehaviorRenderer._crosshairPainter != null &&
        activationMode != ActivationMode.none) {
      final List<CartesianSeriesRenderer> visibleSeriesRenderer =
          crosshairBehaviorRenderer._crosshairPainter!.chartState._chartSeries
              .visibleSeriesRenderers;
      final CartesianSeriesRenderer seriesRenderer = visibleSeriesRenderer[0];
      crosshairBehaviorRenderer._crosshairPainter!._generateAllPoints(Offset(
          seriesRenderer._dataPoints[pointIndex].markerPoint!.x,
          seriesRenderer._dataPoints[pointIndex].markerPoint!.y));
      crosshairBehaviorRenderer._crosshairPainter!.canResetPath = false;
      crosshairBehaviorRenderer
          ._crosshairPainter!.chartState._crosshairRepaintNotifier.value++;
    }
  }
}