开发者

How do I render a Dundas bar chart from most to least?

开发者 https://www.devze.com 2023-02-17 12:26 出处:网络
How does one order the bar chart series to render from most to least? Ordering the data before binding does not seem to help.

How does one order the bar chart series to render from most to least? Ordering the data before binding does not seem to help.

How do I render a Dundas bar chart from most to least?

My code:

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.Ser开发者_运维技巧ies["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";


You need to call Sort() on the series, see http://msdn.microsoft.com/en-us/library/dd455394.aspx. So to sort the points from most to least you'd do


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

There are two other sort methods incase you need to sort by something other than the point value.

0

精彩评论

暂无评论...
验证码 换一张
取 消