How to change legend label orientation ?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
lonelyplanetfr

How to change legend label orientation ?

Post by lonelyplanetfr » Wed Feb 13, 2002 9:46 am

Hi,

I want to use Vertical bar chart with decimal numbers.
Legends in horizontal axis are often overlapping as the size of the chart is 'normal' (not full screen)?

Do you know how to display these figures vertically ?
(I know it was possible with previous versions so I think it 's still possible !)


Do you have a better idea to avoid overlapping ?


thanks

David Gilbert

Re: How to change legend label orientation ?

Post by David Gilbert » Wed Feb 13, 2002 9:59 am

This should do it:

HorizontalCategoryAxis axis = (HorizontalCategoryAxis)plot.getHorizontalAxis();
axis.setVerticalCategoryLabels(true);

One suggestion someone made to avoid overlapping is to clip the labels, printing '...' at the end of strings that have been clipped (and for screen-based charts, use tooltips to show the full name). That's the best suggestion I've heard so far, though I've not had the time to do anything about it yet.

The other thing you can do is make sure that your categories really are categories. If they are dates, then you might be better off using the VerticalXYBarPlot class with a TimeSeriesCollection (implements IntervalXYDataset) for your dataset.

Regards,

DG.

Locked