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 RenderBehaviorArea? parent = parentBox as RenderBehaviorArea?;
  if (parent != null &&
      parent.plotArea != null &&
      parent.plotArea!.firstChild != null) {
    final CartesianSeriesRenderer seriesRenderer =
        parent.plotArea!.firstChild! as CartesianSeriesRenderer;
    final List<num> visibleIndexes = seriesRenderer.visibleIndexes;
    if (visibleIndexes.isNotEmpty &&
        visibleIndexes.first <= pointIndex &&
        pointIndex <= visibleIndexes.last) {
      final num y = seriesRenderer.trackballYValue(pointIndex);
      if (seriesRenderer.xRawValues.isNotEmpty && !y.isNaN) {
        show(seriesRenderer.xRawValues[pointIndex], y.toDouble());
      }
    }
  }
}