buildLegendItems method
Builds the legend item.
Implementation
@override
List<LegendItem>? buildLegendItems(int index) {
final List<LegendItem> legendItems = <LegendItem>[];
final int segmentsCount = segments.length;
for (int i = 0; i < dataCount; i++) {
final ChartLegendItem legendItem = ChartLegendItem(
text: xRawValues[i].toString(),
iconType: toLegendShapeMarkerType(legendIconType, this),
iconColor: effectiveColor(i),
iconBorderWidth: legendIconBorderWidth(),
series: this,
seriesIndex: index,
pointIndex: i,
imageProvider: legendIconType == LegendIconType.image
? parent?.legend?.image
: null,
isToggled: i < segmentsCount && !segmentAt(i).isVisible,
onTap: handleLegendItemTapped,
onRender: _handleLegendItemCreated,
);
legendItems.add(legendItem);
}
return legendItems;
}