George Troulis
George Troulis

Reputation: 168

JFreeChart flip range axis orientation

I'm creating a JFreeChart with 2 range axis, according to this tutorial.

The result of the tutorial looks like this: enter image description here

In this example, the "Secondary" range title reads from top to bottom, but I would like to rotate it 180 degrees and have it read from bottom to top, just like the primary range axis labeled "Value". How can I achieve this?

I looked at the org.jfree.chart.axis api but I didn't find anything relevant to the orientation of the axis titles.

Upvotes: 1

Views: 313

Answers (1)

George Troulis
George Troulis

Reputation: 168

There is no API Support to do this currently (JFreeChart 1.5.0), thanks to trashgod for pointing this out.

The only way to do this currently is to extend the NumberAxis class (which is used to instantiate the chart), and override the drawLabel() method.

To ensure the overridden drawLabel() method is implemented as properly as possible, I would reference the source code for Axis.java in org.jfree.chart.axis. The source code is easy to find online.

The default implementation of drawLabel() is so bulky however that I think I'm not going to try this. It simply isn't worth my time.

Upvotes: 1

Related Questions