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']) {
assert(x != null);
assert(!y.isNaN);
if (coordinateUnit == 'point') {
final RenderBehaviorArea? parent = parentBox as RenderBehaviorArea?;
if (parent != null) {
_position = rawValueToPixelPoint(
x, y, parent.xAxis, parent.yAxis, parent.isTransposed);
}
} else if (coordinateUnit == 'pixel') {
_position = Offset(x, y);
}
if (builder == null) {
_generateAllPoints(position!);
(parentBox as RenderBehaviorArea?)?.invalidate();
} else {
final RenderBehaviorArea? parent = parentBox as RenderBehaviorArea?;
if (parent == null) {
return;
}
if (_position == null) {
return;
}
_generateAllPoints(_position!);
List<CartesianChartPoint> points = <CartesianChartPoint>[];
List<int> currentPointIndices = <int>[];
List<int> visibleSeriesIndices = <int>[];
List<dynamic> visibleSeriesList = <dynamic>[];
TrackballGroupingModeInfo groupingModeInfo;
for (int index = 0; index < chartPointInfo.length; index++) {
final CartesianChartPoint dataPoint =
chartPointInfo[index].chartDataPoint!;
if (tooltipDisplayMode == TrackballDisplayMode.groupAllPoints) {
points.add(dataPoint);
currentPointIndices.add(chartPointInfo[index].dataPointIndex!);
visibleSeriesIndices.add(chartPointInfo[index].seriesIndex);
visibleSeriesList.add(chartPointInfo[index].series!);
}
}
groupingModeInfo = TrackballGroupingModeInfo(
points, currentPointIndices, visibleSeriesIndices, visibleSeriesList);
final List<TrackballDetails> details = <TrackballDetails>[];
for (int i = 0; i < chartPointInfo.length; i++) {
if (tooltipDisplayMode == TrackballDisplayMode.groupAllPoints) {
details
.add(TrackballDetails(null, null, null, null, groupingModeInfo));
break;
} else {
details.add(TrackballDetails(
chartPointInfo[i].chartDataPoint,
chartPointInfo[i].series!,
chartPointInfo[i].dataPointIndex,
chartPointInfo[i].seriesIndex,
));
}
}
parent.trackballBuilder!(details);
points = <CartesianChartPoint>[];
currentPointIndices = <int>[];
visibleSeriesIndices = <int>[];
visibleSeriesList = <CartesianSeries>[];
}
}