.NET chart Datamanipulator

Posted by peter on Stack Overflow See other posts from Stack Overflow or by peter
Published on 2010-12-20T12:23:09Z Indexed on 2010/12/23 12:53 UTC
Read the original article Hit count: 317

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#-4.0