Chart Control Legend Item Ordering
-
Hi everybody! I hope I am posting this question on the correct forum but anyway, I'm having some difficulty getting a Legend on a Chart Control to behave in the way I would like it to. I want the legend to be placed under the chart, and legend items for each series to be added to the legend in the order the series are added to the chart. Say I have 6 series which are added to the chart in order: A, B, C, D, E, F. Suppose that the chart area in which the legend is docked is such a size that the legend has 3 columns. I want the legend to be filled like so: A B C D E F i.e. columns first, then rows. Frustratingly, this is not the behaviour I am getting. As I add the first three series all is fine, and I get a legend with 3 columns and 1 row filled like so: A B C But when I add a 4th series, instead of getting: A B C D as one might expect, the legend looks like this: A C D B Then when I add the next series I get: A C E B D And when I add the final series I get: A C E B D F This is really frustrating me as I have trawled the internet and cannot find any mention of this issue, let alone an answer. Surely wanting the legend to be filled columns first, then rows, would be the most logical way of doing it, so I can't believe that the .NET guys haven't allowed for this possibility. Anyway, my legend is set with the following properties: Legend legend = new Legend("Legend1"); legend.LegendItemOrder = LegendItemOrder.ReversedSeriesOrder; legend.Alignment = StringAlignment.Center; legend.Docking = Docking.Bottom; legend.LegendStyle = LegendStyle.Table; legend.TableStyle = LegendTableStyle.Wide; legend.IsEquallySpacedItems = true; legend.AutoFitMinFontSize = 6; legend.IsTextAutoFit = true; chart.Legends.Add(legend); Can anyone please help me? Thanks, Nick
-
Hi everybody! I hope I am posting this question on the correct forum but anyway, I'm having some difficulty getting a Legend on a Chart Control to behave in the way I would like it to. I want the legend to be placed under the chart, and legend items for each series to be added to the legend in the order the series are added to the chart. Say I have 6 series which are added to the chart in order: A, B, C, D, E, F. Suppose that the chart area in which the legend is docked is such a size that the legend has 3 columns. I want the legend to be filled like so: A B C D E F i.e. columns first, then rows. Frustratingly, this is not the behaviour I am getting. As I add the first three series all is fine, and I get a legend with 3 columns and 1 row filled like so: A B C But when I add a 4th series, instead of getting: A B C D as one might expect, the legend looks like this: A C D B Then when I add the next series I get: A C E B D And when I add the final series I get: A C E B D F This is really frustrating me as I have trawled the internet and cannot find any mention of this issue, let alone an answer. Surely wanting the legend to be filled columns first, then rows, would be the most logical way of doing it, so I can't believe that the .NET guys haven't allowed for this possibility. Anyway, my legend is set with the following properties: Legend legend = new Legend("Legend1"); legend.LegendItemOrder = LegendItemOrder.ReversedSeriesOrder; legend.Alignment = StringAlignment.Center; legend.Docking = Docking.Bottom; legend.LegendStyle = LegendStyle.Table; legend.TableStyle = LegendTableStyle.Wide; legend.IsEquallySpacedItems = true; legend.AutoFitMinFontSize = 6; legend.IsTextAutoFit = true; chart.Legends.Add(legend); Can anyone please help me? Thanks, Nick
I'm sure you have searched plenty http://stackoverflow.com/questions/1917798/ms-chart-control-change-the-order-of-series-in-a-legend[^] I don't know the complexity of your chart, but I do know that the order in which you load the series to the chart is important, and what type of chart you select as well such as a series chart with plot lines. I guess take a pie chart, now you have a legend to explain the pieces of the pie, there really is no order to it. Unless the largest pieces of the pie down to the smallest are the order. I've always had to experiment for hours to get them right, and after 100's of them, narrow down which charts to stay away from. I'm not sure if you can do multiple legends, and display them in rows or columns. Not the answer you want, but your going have to take to pencil and paper and record your results based on what you get, or try the Microsoft Forum for Chart Control at asp.net