How to change the x-axis label angle?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
simplename
Posts: 6
Joined: Mon Jan 07, 2008 2:08 am

How to change the x-axis label angle?

Post by simplename » Mon Jan 07, 2008 2:54 am

I've created a chart using the ChartFactory class createBarChart method and now I need to change the angles of the labels of the x-axis just like the demo DualAxisDemo1.png on this website (I can't post any URL's =( )

I've noticed a method in the Axis class setLabelAngle(), but I can't use it unless I can grab hold of the X-axis object created in the graph.

Any ideas on how to do this?

Thank you.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Mon Jan 07, 2008 12:50 pm

To get a reference to the axis:

Code: Select all

CategoryPlot plot = (CategoryPlot) chart.getPlot();
CategoryAxis axis = plot.getDomainAxis();
The source code for all the demos is available to download when you buy the JFreeChart Developer Guide - it will save you a lot of time I think.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked