show method
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 CartesianStateProperties stateProperties = _stateProperties;
final TrackballRenderingDetails trackballRenderingDetails =
TrackballHelper.getRenderingDetails(
_stateProperties.trackballBehaviorRenderer);
final List<CartesianSeriesRenderer> visibleSeriesRenderer =
stateProperties.chartSeries.visibleSeriesRenderers;
if (visibleSeriesRenderer.isEmpty) {
return;
}
final SeriesRendererDetails seriesRendererDetails =
SeriesHelper.getSeriesRendererDetails(visibleSeriesRenderer.firstWhere(
(CartesianSeriesRenderer element) =>
SeriesHelper.getSeriesRendererDetails(element)
.visibleDataPoints !=
null));
if (trackballRenderingDetails.trackballPainter != null || builder != null) {
final ChartAxisRendererDetails xAxisDetails =
seriesRendererDetails.xAxisDetails!;
if (coordinateUnit != 'pixel') {
final ChartLocation location = calculatePoint(
(x is DateTime && (xAxisDetails is! DateTimeCategoryAxisDetails))
? x.millisecondsSinceEpoch
: ((x is DateTime &&
xAxisDetails is DateTimeCategoryAxisDetails)
? xAxisDetails.labels
.indexOf(xAxisDetails.dateFormat.format(x))
: ((x is String && xAxisDetails is CategoryAxisDetails)
? xAxisDetails.labels.indexOf(x)
: x)),
y,
xAxisDetails,
seriesRendererDetails.yAxisDetails!,
seriesRendererDetails.stateProperties.requireInvertedAxis,
seriesRendererDetails.series,
seriesRendererDetails.stateProperties.chartAxis.axisClipRect);
x = location.x;
y = location.y;
}
if (seriesRendererDetails.visibleDataPoints!.isNotEmpty == true) {
if (trackballRenderingDetails.trackballPainter != null) {
trackballRenderingDetails.isTrackballTemplate = false;
trackballRenderingDetails.generateAllPoints(Offset(x.toDouble(), y));
} else if (builder != null && (!trackballRenderingDetails.isMoving)) {
trackballRenderingDetails
.showTemplateTrackball(Offset(x.toDouble(), y));
}
}
}
if (trackballRenderingDetails.trackballPainter != null) {
trackballRenderingDetails.trackballPainter!.canResetPath = false;
stateProperties.repaintNotifiers['trackball']!.value++;
}
}