Hi there,
Please forgive me for not giving you all more time to come up with some ideas; here after, I'll explain what I did to get what I needed and leave all a question I was not able to find anything about.
All in all, customizing legend items was not as straight forward as I expected. I had to take the following steps:
1) Chart's legend has to be set to : LegendItemOrder="SameAsSeriesOrder", otherwise the result is all unorganized.
2) Modified the CustomizeLegend event as follows:
protected void PieChart_CustomizeLegend(object sender, CustomizeLegendEventArgs e)
{
foreach (LegendItem lgItem in e.LegendItems)
{
if (!string.IsNullOrEmpty(lgItem.Name))
{
LegendItem cstItem = new LegendItem();
cstItem.ImageStyle = LegendImageStyle.Marker;
cstItem.MarkerColor = lgItem.Color;
cstItem.Name = lgItem.Name;
cstItem.MarkerStyle = MarkerStyle.Diamond;
cstItem.MarkerSize = 15;
((Chart)sender).Legends[0].CustomItems.Add(cstItem);
}
}
((Chart)sender).Series[0].IsVisibleInLegend = false;
((Chart)sender).CustomizeLegend -= PieChart_CustomizeLegend;
}
Note that set the series
IsVisibleInLegend property inside the event and not in the markup. If done in there, nothing will be drawn in the legend.
Moreover, I noticed that, somehow I cannot explain, the
CustomizeLegend event was begin fired three times, giving undesired results, thus the un-subscription.