getDetailsForSeriesDatum method
Get an expanded set of processed DatumDetails for a given SeriesDatum.
This is typically called by chart behaviors that need to get full details on selected data.
Implementation
@override
DatumDetails<D> getDetailsForSeriesDatum(SeriesDatum<D> seriesDatum) {
// Generate details relevant to every type of series renderer. Position
// details are left as an exercise for every renderer that extends this
// class.
final series = seriesDatum.series;
final index = seriesDatum.index;
final domainFn = series.domainFn;
final domainLowerBoundFn = series.domainLowerBoundFn;
final domainUpperBoundFn = series.domainUpperBoundFn;
final measureFn = series.measureFn;
final measureLowerBoundFn = series.measureLowerBoundFn;
final measureUpperBoundFn = series.measureUpperBoundFn;
final measureOffsetFn = series.measureOffsetFn;
final rawMeasureFn = series.rawMeasureFn;
final rawMeasureLowerBoundFn = series.rawMeasureLowerBoundFn;
final rawMeasureUpperBoundFn = series.rawMeasureUpperBoundFn;
final colorFn = series.colorFn;
final areaColorFn = series.areaColorFn ?? colorFn;
final fillColorFn = series.fillColorFn ?? colorFn;
final radiusPxFn = series.radiusPxFn;
final strokeWidthPxFn = series.strokeWidthPxFn;
final domainValue = domainFn(index);
final domainLowerBoundValue = domainLowerBoundFn?.call(index);
final domainUpperBoundValue = domainUpperBoundFn?.call(index);
final measureValue = measureFn(index);
final measureLowerBoundValue = measureLowerBoundFn?.call(index);
final measureUpperBoundValue = measureUpperBoundFn?.call(index);
final measureOffsetValue = measureOffsetFn?.call(index);
final rawMeasureValue = rawMeasureFn(index);
final rawMeasureLowerBoundValue = rawMeasureLowerBoundFn?.call(index);
final rawMeasureUpperBoundValue = rawMeasureUpperBoundFn?.call(index);
final color = colorFn!(index);
// Fill color is an optional override for color. Make sure we get a value if
// the series doesn't define anything specific.
var fillColor = fillColorFn!(index);
fillColor ??= color;
// Area color is entirely optional.
final areaColor = areaColorFn!(index);
var radiusPx = radiusPxFn?.call(index)?.toDouble();
radiusPx = radiusPx;
var strokeWidthPx = strokeWidthPxFn?.call(index)?.toDouble();
strokeWidthPx = strokeWidthPx;
final details = DatumDetails<D>(
datum: seriesDatum.datum,
index: seriesDatum.index,
domain: domainValue,
domainLowerBound: domainLowerBoundValue,
domainUpperBound: domainUpperBoundValue,
measure: measureValue,
measureLowerBound: measureLowerBoundValue,
measureUpperBound: measureUpperBoundValue,
measureOffset: measureOffsetValue,
rawMeasure: rawMeasureValue,
rawMeasureLowerBound: rawMeasureLowerBoundValue,
rawMeasureUpperBound: rawMeasureUpperBoundValue,
series: series,
color: color,
fillColor: fillColor,
areaColor: areaColor,
radiusPx: radiusPx,
strokeWidthPx: strokeWidthPx,
);
// chartPosition depends on the shape of the rendered elements, and must be
// added by concrete [SeriesRenderer] classes.
return addPositionToDetailsForSeriesDatum(details, seriesDatum);
}