horizontal bar chart - bad usage of horizontal space

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
pstanton
Posts: 3
Joined: Tue May 06, 2008 5:51 am

horizontal bar chart - bad usage of horizontal space

Post by pstanton » Tue May 06, 2008 6:13 am

I've got a bar chart which, in an attempt to have the full label display i've set to PlotOrientation.HORIZONTAL. The result is a little baffling - the label is still truncated (Jason Pre...) and there is a full 50 pixels of unused space left of the 'Employee' label.

http -> img74.imageshack.us/img74/7974/chartsps7.png
(it wouldn't let me post a proper url)

this is the actual png generated.

I'd at least expect there to be less white space and more of the label displayed, and preferable still, the space taken up by the bar chart its self would reduce so that the label is never truncated.

why is this happening? how can i avoid it?

also, i did have this layed out vertically, but i couldn't figure out how to have the label wrap on to two lines. is that possible?

paul.

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 » Tue May 06, 2008 1:27 pm

I can't see your sample chart, because my (temporary) ISP blocks quite a few sites, including that one.

But I do recall a bug in the category axis labelling that was fixed either late last year or early this year. Are you using the latest (1.0.9) release?

Methods you should look at in the CategoryAxis class are:

Code: Select all

public void setMaximumCategoryLabelLines(int lines); - defaults to 1
public void setMaximumCategoryLabelWidthRatio(float ratio); - try setting this to 0.6 or 0.7 and see what happens.
David Gilbert
JFreeChart Project Leader

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

pstanton
Posts: 3
Joined: Tue May 06, 2008 5:51 am

Post by pstanton » Wed May 07, 2008 3:42 am

i am using 1.0.9.

i've changed the maximumCategoryLabelLines and that seems to help, but that's caused another little annoyance: the text block as a whole is right aligned so it sits against the chart, but the wrapped lines within the text block are aligned centre - this makes the labels appear all over the place with some labels longer than others, it looks like nothing lines up at all.

is there a way to change the alignment of the multi-line category labels?

Locked