How do I change the order of series in a legend?
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;
Forgive the poor ASCII art, but the legend looks like:
.......[yellow] s2 .......[red] s3 ......[blue] s1 ............
when I would like it to go in order: s1, s2, s3.
Any ideas?
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.