addPositionToDetailsForSeriesDatum method
DatumDetails<D>
addPositionToDetailsForSeriesDatum(
- DatumDetails<
D> details, - SeriesDatum<
D> seriesDatum
override
Adds chart position data to details
.
This is a helper function intended to be called from getDetailsForSeriesDatum. Every concrete SeriesRenderer needs to implement custom logic for setting location data.
Implementation
@override
DatumDetails<D> addPositionToDetailsForSeriesDatum(
DatumDetails<D> details, SeriesDatum<D> seriesDatum) {
final series = details.series!;
final domainAxis = series.getAttr(domainAxisKey) as ImmutableAxis<D>;
final measureAxis = series.getAttr(measureAxisKey) as ImmutableAxis<num>;
final point = getPoint(
seriesDatum.datum,
details.domain,
details.domainLowerBound,
details.domainUpperBound,
series,
domainAxis,
details.measure,
details.measureLowerBound,
details.measureUpperBound,
details.measureOffset,
measureAxis);
final symbolRendererFn = series.getAttr(pointSymbolRendererFnKey);
// Get the ID of the [SymbolRenderer] for this point. An ID may be
// specified on the datum, or on the series. If neither is specified,
// fall back to the default.
String? symbolRendererId;
if (symbolRendererFn != null) {
symbolRendererId = symbolRendererFn(details.index);
}
symbolRendererId ??= series.getAttr(pointSymbolRendererIdKey);
symbolRendererId ??= defaultSymbolRendererId;
// Now that we have the ID, get the configured [SymbolRenderer].
SymbolRenderer? nearestSymbolRenderer;
if (symbolRendererId == defaultSymbolRendererId) {
nearestSymbolRenderer = symbolRenderer;
} else {
final id = symbolRendererId;
if (!config.customSymbolRenderers!.containsKey(id)) {
throw ArgumentError('Invalid custom symbol renderer id "$id"');
}
nearestSymbolRenderer = config.customSymbolRenderers![id];
}
return DatumDetails.from(details,
chartPosition: NullablePoint(point.x, point.y),
chartPositionLower: NullablePoint(point.xLower, point.yLower),
chartPositionUpper: NullablePoint(point.xUpper, point.yUpper),
symbolRenderer: nearestSymbolRenderer);
}