assignMissingColors method

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

Assigns missing colors in case when color accessor functions are not set.

Assigned color is based on the depth of each node.

Implementation

@override
void assignMissingColors(Iterable<MutableSeries<D>> seriesList,
    {required bool emptyCategoryUsesSinglePalette}) {
  for (final series in seriesList) {
    final colorPalettes =
        StyleFactory.style.getOrderedPalettes(series.data.length);
    final count = colorPalettes.length;

    series.fillColorFn ??= (int? index) {
      var node = series.data[index!] as TreeNode<Object>;
      return colorPalettes[node.depth % count].shadeDefault;
    };

    // Pattern color and stroke color defaults to the default config stroke
    // color if no accessor is provided.
    series.colorFn ??= (index) => config.strokeColor;
    series.patternColorFn ??= (index) => config.strokeColor;
  }
}