show method
Displays the crosshair at the specified x and y-positions.
x & y - x and y values/pixel where the crosshair needs to be shown.
coordinateUnit - specify the type of x and y values given.'pixel' or 'point' for logica pixel and chart data point respectively.
Defaults to 'point'
.
Implementation
void show(dynamic x, double y, [String coordinateUnit = 'point']) {
final SfCartesianChartState chartState = _chartState!;
final CrosshairBehaviorRenderer crosshairBehaviorRenderer =
chartState._crosshairBehaviorRenderer;
if (coordinateUnit != 'pixel') {
final CartesianSeriesRenderer seriesRenderer = crosshairBehaviorRenderer
._crosshairPainter!.chartState._chartSeries.visibleSeriesRenderers[0];
final ChartAxisRenderer xAxisRenderer = seriesRenderer._xAxisRenderer!;
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.truncateToDouble();
}
if (crosshairBehaviorRenderer._crosshairPainter != null &&
activationMode != ActivationMode.none &&
x != null) {
crosshairBehaviorRenderer._crosshairPainter!
._generateAllPoints(Offset(x.toDouble(), y));
crosshairBehaviorRenderer._crosshairPainter!.canResetPath = false;
crosshairBehaviorRenderer
._crosshairPainter!.chartState._crosshairRepaintNotifier.value++;
}
}