How to get the X-Axis labels vertical instead of horizontal

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Bowser
Posts: 10
Joined: Thu Jun 26, 2008 5:27 pm

How to get the X-Axis labels vertical instead of horizontal

Post by Bowser » Fri Jul 11, 2008 1:50 pm

Hi Folks,

here is my problem:

I have a Bar Chart Diagramm which has Date Values on the X-Axis. The Format is in 'DD.MM.YYYY'
Now i've got the problem that the dates are written horizontal. So i can only show few values.
But i want to show more values.
So i need to switch the Dates to vertical.

Is there any method to do this?

Hope you can help me!

Thanks!!

RoyW
Posts: 93
Joined: Wed Apr 23, 2008 7:42 pm
Contact:

Post by RoyW » Fri Jul 11, 2008 5:41 pm

The answer does not come from thinking outside the box, rather the answer comes from realizing the truth; There is no Box. my js site

Bowser
Posts: 10
Joined: Thu Jun 26, 2008 5:27 pm

Post by Bowser » Sat Jul 12, 2008 8:29 am

Hi Roy,

Thank You for your quick answer!

But unfortunately it doesn't work. Maybe i've done something wrong?

Here my Code:

Code: Select all

        CategoryPlot catPlot = chart.getCategoryPlot();

        CategoryAxis domainAxis = catPlot.getDomainAxis();
        domainAxis.setVerticalTickLabels(true);
Is there any misstake?

RoyW
Posts: 93
Joined: Wed Apr 23, 2008 7:42 pm
Contact:

Post by RoyW » Mon Jul 14, 2008 1:36 pm

Bowser wrote: I have a Bar Chart Diagramm which has Date Values on the X-Axis. The Format is in 'DD.MM.YYYY'
Bowser wrote: Here my Code:

Code: Select all

CategoryAxis domainAxis = catPlot.getDomainAxis();
Usually I display dates with a DateAxis so I am confused. Maybe you should post more code. Maybe a complete example.
The answer does not come from thinking outside the box, rather the answer comes from realizing the truth; There is no Box. my js site

travis_cooper
Posts: 6
Joined: Thu Jul 17, 2008 3:57 pm
Location: Salt Lake City, Utah

Post by travis_cooper » Thu Jul 17, 2008 3:59 pm

This is how I do it.

Code: Select all

JFreeChart chart = .....;
CategoryAxis axis = chart.getCategoryPlot().getDomainAxis();
axis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
Normally I use UP_45, but the 90 should get you vertical. Also you can use either up or down to change the direction of the text.
Travis

Locked