generateDefaultNodeColorMap function
Generates a default node color map for a list of SankeyNode objects
Each node's displayLabel is used to assign a color from defaultNodeColors
in sequence (cycling through the palette). This is useful as a convenience
method when no custom node colors are provided.
Returns a Map with the node's display label as key and the assigned Color as value
Implementation
Map<String, Color> generateDefaultNodeColorMap(List<SankeyNode> nodes) {
final Map<String, Color> colorMap = {};
for (int i = 0; i < nodes.length; i++) {
final label = nodes[i].displayLabel;
if (!colorMap.containsKey(label)) {
colorMap[label] = defaultNodeColors[i % defaultNodeColors.length];
}
}
return colorMap;
}