MS图表控件:更改图例中系列的顺序 [英] MS Chart Control: Change the order of series in a legend
问题描述
如何更改图例中系列的顺序?
How do I change the order of series in a legend?
我的行系列出现在我的StackedColumn系列之前,但出现在我的Column系列之后.
My Line series is appearing before my StackedColumn series, but after my Column series.
Chart c = new Chart();
ChartArea ca = c.ChartAreas.Add("main");
Legend lg = c.Legends.Add("mainLegend");
Series s1 = c.Series.Add("s1");
s1.ChartType = ChartType.StackedColumn;
Series s2 = c.Series.Add("s2");
s2.ChartType = ChartType.Column;
Series s3 = c.Series.Add("s3");
s3.ChartType = ChartType.Line;
原谅可怜的ASCII艺术,但图例看起来像:
Forgive the poor ASCII art, but the legend looks like:
........ [黄色] s2 ....... [红色] s3 ...... [蓝色] s1 ............
.......[yellow] s2 .......[red] s3 ......[blue] s1 ............
当我希望按顺序进行时:s1,s2,s3.
when I would like it to go in order: s1, s2, s3.
有什么想法吗?
推荐答案
这确实很奇怪.在我看来,图例中系列的顺序应该与添加顺序相同,或者如果您将Legend
实例的LegendItemOrder
属性设置为ReversedSeriesOrder
,则顺序相反.
That seems very strange indeed. To me it seems that the order of the series in the legend should be the same as the order in which you add them, or if you set the LegendItemOrder
property of your Legend
instance to ReversedSeriesOrder
in the reversed order.
这篇关于MS图表控件:更改图例中系列的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!