I have two graphs that each represent the same set of data. When I add each series to each graph, the order of each series item is different from one to the next. How do I control the order of items in the legend? Alphabetical is fine, but I'd prefer to set the order myself.
Series: Coal, Gas, Nuclear, Instruments, Forward Power, Other
Currently Displays:
Graph 1 Legend: Forward Power, Gas, Coal, Nuclear, Instruments, Other
Graph 2 Legend: Nuclear, Coal, Gas, Instruments, Forward Power, Other
Preferred:
Graph 2 Legend: Forward Power, Gas, Coal, Nuclear, Instruments, Other
The legends should always display the series in the same order they appear in the series collection. Are these composite charts? Can you post a sample of how you're setting up your charts?Sorry, but there is no mechanism that would allow you to sort legend items, other than re-arranging the order of the series.
That's what I assumed and was working on when I posted this comment. What you are saying is mostly true...
Before i posted my question, I tried rearranging the series but it would not change on my chart. What I had to do was 1) remove them from the chart layer 2) reorder each series item 3) Add them back to the chart layer.
It seems that, once they are added to a chart layer, altering the order of the series does not affect the legend order.
Regards,
Ryan
It looks like simply re-arranging the series order doesn't trigger the chart's update, unlike adding or removing series. You should still be able to change the order without having to add or remove series, just have to call chart.InvalidateLayers() afterwards.
I was doing this at design time. However, that is useful information and I may be able to apply that in the future. Thanks again!