legend function
Implementation
Widget legend(ChartConfig config) {
return Wrap(
spacing: 16,
runSpacing: 8,
children: config.series.asMap().entries.map((entry) {
final index = entry.key;
final series = entry.value;
final fallback = getDefaultSeriesColor(index);
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 16,
height: 16,
color:
series.color ??
safeStringToColor(series.itemStyle?.color, fallback),
),
const SizedBox(width: 4),
Text(series.name ?? 'Series ${index + 1}'),
],
);
}).toList(),
);
}