generateDefaultNodeColorMap function
Generates a default node color map for a list of SankeyNode objects
Each node's label
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 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].label;
if (label != null && !colorMap.containsKey(label)) {
colorMap[label] = defaultNodeColors[i % defaultNodeColors.length];
}
}
return colorMap;
}