show method

void show(
  1. dynamic x,
  2. double y, [
  3. String coordinateUnit = 'point'
])

Displays the trackball at the specified x and y-positions.

*x and y - x & y pixels/values at which the trackball needs to be shown.

coordinateUnit - specify the type of x and y values given.

'pixel' or 'point' for logical pixel and chart data point respectively.

Defaults to 'point'.

Implementation

void show(dynamic x, double y, [String coordinateUnit = 'point']) {
  final SfCartesianChartState chartState = _chartState!;
  final TrackballBehaviorRenderer trackballBehaviorRenderer =
      chartState._trackballBehaviorRenderer;
  final List<CartesianSeriesRenderer> visibleSeriesRenderer =
      chartState._chartSeries.visibleSeriesRenderers;
  final CartesianSeriesRenderer seriesRenderer = visibleSeriesRenderer[0];
  if ((trackballBehaviorRenderer._trackballPainter != null ||
          builder != null) &&
      activationMode != ActivationMode.none) {
    final ChartAxisRenderer xAxisRenderer = seriesRenderer._xAxisRenderer!;
    if (coordinateUnit != 'pixel') {
      final _ChartLocation location = _calculatePoint(
          (x is DateTime && xAxisRenderer is! DateTimeCategoryAxisRenderer)
              ? x.millisecondsSinceEpoch
              : ((x is DateTime &&
                      xAxisRenderer is DateTimeCategoryAxisRenderer)
                  ? xAxisRenderer._labels
                      .indexOf(xAxisRenderer._dateFormat.format(x))
                  : ((x is String && xAxisRenderer is CategoryAxisRenderer)
                      ? xAxisRenderer._labels.indexOf(x)
                      : x)),
          y,
          xAxisRenderer,
          seriesRenderer._yAxisRenderer!,
          seriesRenderer._chartState!._requireInvertedAxis,
          seriesRenderer._series,
          seriesRenderer._chartState!._chartAxis._axisClipRect);
      x = location.x;
      y = location.y;
    }
    if (trackballBehaviorRenderer._trackballPainter != null) {
      trackballBehaviorRenderer._isTrackballTemplate = false;
      trackballBehaviorRenderer._generateAllPoints(Offset(x.toDouble(), y));
    } else if (builder != null && (!trackballBehaviorRenderer._isMoving)) {
      trackballBehaviorRenderer
          ._showTemplateTrackball(Offset(x.toDouble(), y));
    }
  }

  if (trackballBehaviorRenderer._trackballPainter != null) {
    trackballBehaviorRenderer._trackballPainter!.canResetPath = false;
    chartState._trackballRepaintNotifier.value++;
  }
}