2010-12-20 40 views
0

在.NET C#4.0與.NET圖表控制我有這樣的代碼,以生成餅圖:.NET圖表Datamanipulator

 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"); 

這種運作良好,它生成與頂部10的用戶的餅圖顯示他們的總訂單金額。 我想將DataPoints的legendtext設置爲order.UserName屬性。問題是,DataManipulator.Group會覆蓋系列數據點。所以如果我在foreach循環中設置legendtext,它們將在Group調用後被擦除。

在Group調用之後,我沒有看到一種方法來檢索DataPoint的正確UserName來設置legendtext。

這種情況的最佳方法是什麼?

回答

1

作爲一種解決方案,我使用LINQ對數據源進行分組,並放棄使用DataManipulator。