tooltipInfo method
TooltipInfo?
tooltipInfo(
{ - Offset? position,
- int? pointIndex,
})
override
Implementation
@override
TooltipInfo? tooltipInfo({Offset? position, int? pointIndex}) {
if (segmentRect != null) {
final int dataSourceLength = series.dataSource!.length;
pointIndex ??= currentSegmentIndex;
final CartesianChartPoint<D> chartPoint = _chartPoint();
final TooltipBehavior tooltipBehavior = series.parent!.tooltipBehavior!;
final int digits = tooltipBehavior.decimalPlaces;
final TooltipPosition tooltipPosition = tooltipBehavior.tooltipPosition;
final ChartMarker marker = series.markerAt(pointIndex);
final double markerHeight =
series.markerSettings.isVisible ? marker.height / 2 : 0;
final Offset preferredPos = tooltipPosition == TooltipPosition.pointer
? position ?? segmentRect!.outerRect.topCenter
: segmentRect!.outerRect.topCenter;
return ChartTooltipInfo<T, D>(
primaryPosition:
series.localToGlobal(preferredPos.translate(0, -markerHeight)),
secondaryPosition:
series.localToGlobal(preferredPos.translate(0, markerHeight)),
text: _tooltipTextFormat(chartPoint, digits),
header: tooltipBehavior.shared
? _tooltipText(series.tooltipHeaderText(chartPoint), digits)
: series.name,
data: series.dataSource![
pointIndex >= dataSourceLength ? dataSourceLength - 1 : pointIndex],
point: chartPoint,
series: series.widget,
renderer: series,
seriesIndex: series.index,
segmentIndex: currentSegmentIndex,
pointIndex: pointIndex,
markerColors: <Color?>[fillPaint.color],
markerType: marker.type,
);
}
return null;
}