assignMissingColors method

  1. @override
void assignMissingColors(
  1. Iterable<MutableSeries<D>> seriesList, {
  2. required bool emptyCategoryUsesSinglePalette,
})

Assigns colors to series that are missing their colorFn.

Implementation

@override
void assignMissingColors(Iterable<MutableSeries<D>> seriesList,
    {required bool emptyCategoryUsesSinglePalette}) {
  var maxMissing = 0;

  seriesList.forEach((series) {
    if (series.colorFn == null) {
      maxMissing = max(maxMissing, series.data.length);
    }
  });

  if (maxMissing > 0) {
    final colorPalettes = StyleFactory.style.getOrderedPalettes(1);
    final colorPalette = colorPalettes[0].makeShades(maxMissing);

    seriesList.forEach((series) {
      series.colorFn ??= (index) => colorPalette[index!];
    });
  }
}