Long Titles On Charts

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
mjacobsca
Posts: 16
Joined: Thu Aug 21, 2003 4:59 pm

Long Titles On Charts

Post by mjacobsca » Mon Sep 29, 2003 7:31 am

I have a few charts that end up with long titles, and the titles end up getting clipped off the right side of the chart. I'd like to be able to improve this situation if possible. I've looked at prior posts on the subject, but haven't found one that gives me a good idea on the best way to approach this.

I've looked at the TextTitle class, and considered a few fixes to solve my problem, but i'm wondering if there is a definite "good" approach to take here. For example, am I better of shrinking the text to fit? Or should I consider wrapping the text? If so, how does the chart know that the title is bigger (height) than what was expected? Should I enlarge the chart size?

As you can see, there are a lot of possibilities here. But until I start coding one of them, I won't really know the difficulties I will face since I don't know the graphing code that well at this point.

Therefore, does anyone have a suggestion on how they may have approached this and what the best ways to tackle the problem are?

Thanks,

Michael

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 Sep 29, 2003 9:43 pm

I think a good approach is to wrap the text. The layout method used by JFreeChart assigns each title its preferred space and the plot gets to use whatever is left. You'll need to modify the getPreferredHeight() method to return the height required for the wrapped text.
David Gilbert
JFreeChart Project Leader

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

Locked