preprocessSeries method

Map<String, List<MutableSeries<D>>> preprocessSeries(
  1. List<MutableSeries<D>> seriesList
)

Preprocess series to allow stacking and other mutations.

Build a map of rendererId to series.

Implementation

Map<String, List<MutableSeries<D>>> preprocessSeries(
    List<MutableSeries<D>> seriesList) {
  final rendererToSeriesList = <String, List<MutableSeries<D>>>{};

  var unusedRenderers = _usingRenderers;
  _usingRenderers = <String>{};

  // Build map of rendererIds to SeriesLists.
  seriesList.forEach((MutableSeries<D> series) {
    final rendererId = series.getAttr(rendererIdKey)!;
    rendererToSeriesList.putIfAbsent(rendererId, () => []).add(series);

    _usingRenderers.add(rendererId);
    unusedRenderers.remove(rendererId);
  });

  // Allow unused renderers to render out content.
  unusedRenderers
      .forEach((rendererId) => rendererToSeriesList[rendererId] = []);

  // Have each renderer preprocess their seriesLists.
  rendererToSeriesList.forEach((rendererId, seriesList) {
    getSeriesRenderer(rendererId).preprocessSeries(seriesList);
  });

  return rendererToSeriesList;
}