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;

  for (final series in seriesList) {
    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);

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