Mattimus Max
Mattimus Max

Reputation: 61

With JFreeCharts, how can I sort the x-axis labels and legend items separately?

I have a multi-lined chart that contains the following data:

Line 1: Name=B, X-Axis Label=A Line 2: Name=A, X-Axis Label=C Line 3: Name=C, X-Axis Label=B

I would like the x-axis labels to show up in the order: A, B, C, and I would like for the legend items to display in that same order. However, depending on the order the data is in when I give it to the chart, one of these may be true but not both.

Is there some class that can be overridden to order x-axis labels and another to order legend items? Or is there an alternative/better solution?

Any help or suggestions would be appreciated, thank you.

Upvotes: 1

Views: 1066

Answers (1)

jzd
jzd

Reputation: 23639

Override getLegendItems() in your Renderer.

Upvotes: 1

Related Questions