2011-03-16 78 views
0

如何訂購條形圖系列從最多到最少?在綁定之前訂購數據似乎沒有幫助。如何渲染Dundas條形圖從最多到最少?

bar chart that that is rendering least to most

我的代碼:

chart.Series.Add("port"); 
chart.Series["port"].Type = SeriesChartType.Bar; 
chart.Series["port"]["PointWidth"] = "0.6"; 
chart.Series["port"]["BarLabelStyle"] = "Center"; 
chart.Series["port"].ShowLabelAsValue = true; 
chart.Series["port"].Points.DataBind(myData, "Key", "Value", "Label=Value{p2}"); 
chart.Series["port"].BorderStyle = ChartDashStyle.Solid; 
chart.Series["port"].BorderColor = Color.White; 
chart.Series["port"].BorderWidth = 1; 
chart.Series["port"].ShowLabelAsValue = true; 
chart.Series["port"].Font = myfont; 

chart.ChartAreas.Add("Default"); 
chart.ChartAreas["Default"].BackColor = Color.Transparent; 
foreach (var axis in chart.ChartAreas["Default"].Axes) 
{ 
    axis.LabelStyle.Font = myfont; 
    axis.MajorGrid.Enabled = false; 
} 
chart.ChartAreas["Default"].AxisX.Interval = 1; 
chart.ChartAreas["Default"].AxisY.LabelStyle.Format = "p0"; 
+0

你只是想扭轉你有什麼對現在的訂單? – jcolebrand 2011-03-16 22:42:07

+0

@drachenstein是的。因此,在上面的圖表圖像中,按照從上到下的順序,會看到加拿大,美國和歐盟。 – LordHits 2011-03-17 00:54:04

回答

0

你需要排序調用()上連載,看http://msdn.microsoft.com/en-us/library/dd455394.aspx。因此,從多到少,你會怎麼做

 

chart.Series["port"].Sort(PointSortOrder.Descending); 
 

還有其他兩個排序方法櫃面你需要比點值以外的東西來排序分排序。

+1

此調用需要在調用DataBind方法後進行。如果之前被調用,則排序不起作用。 – LordHits 2011-03-21 13:44:59