In .NET C#4.0 with the .NET Chart control I have this code to generate a pie chart:
chart.Series[0].ChartType = SeriesChartType.Pie;
foreach (Order order in orderCollection) {
// If I set point.LegendText = order.UserName, .Group will erase it
chart.Series[0].Points.AddXY(order.UserName, order.Total);
}
chart.DataManipulator.Sort(PointSortOrder.Ascending, "X", "Series1");
chart.DataManipulator.Group("SUM", 1, IntervalType.Months, "Series1");
This works well, it generates a pie chart with the top 10 users showing their total order sum.
I would like to set the DataPoints' legendtext to the order.UserName property. The problem is, DataManipulator.Group overwrites the series DataPoints. So if I set the legendtext in the foreach loop, they will be erased after the Group call.
And after the Group call, I don't see a way to retrieve the correct UserName for a DataPoint to set the legendtext.
What is the best approach for this situation?