How to change font for tooltips

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
LukasW
Posts: 9
Joined: Thu Nov 02, 2006 8:10 pm

How to change font for tooltips

Post by LukasW » Wed Jun 04, 2008 1:55 pm

Hi,

I'm trying to find a way to set the font for the tooltips generated by my StandardXYToolTipGenerator. I can't find where to set the property. The text in the tooltips is now very big and I want it smaller.

Thanx,
Lukas

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Wed Jun 04, 2008 6:47 pm

Like every other swing tooltip, the font and appearance are determined by the look and feel. However, every swing text component (including tooltips) supports the display of HTML. So you can specify some formatted HTML in the StandardXYToolTipGenerator.

For example, this string should work as expected for the formatString argument

Code: Select all

"<html><body>{0} = {2} <font size="7">{1}</font></body></html>"

LukasW
Posts: 9
Joined: Thu Nov 02, 2006 8:10 pm

Post by LukasW » Thu Jun 05, 2008 9:39 am

OK, but my graph is not part of a swing GUI, it's displayed as a .png image in a webapplication. Is there no way to simply pass a Font object to some renderer or tooltip generator in JFreeChart?

if i do this:

Code: Select all

XYToolTipGenerator vasToolTipGenerator = new StandardXYToolTipGenerator("<html><body>{0} = {2} <font size=\"7\">{1}</font></body></html>", new SimpleDateFormat("yyyyMMdd HH:mm"), new DecimalFormat("#0.0"));
the tooltip doesn't get formatted, only shows the code

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 » Thu Jun 05, 2008 10:10 am

Then the tooltip font is controlled by the browser displaying the image (and associated HTML image map). There's nothing (I'm aware of) that JFreeChart can do to control that.
David Gilbert
JFreeChart Project Leader

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

LukasW
Posts: 9
Joined: Thu Nov 02, 2006 8:10 pm

Post by LukasW » Thu Jun 05, 2008 12:48 pm

Thank you, I see now how it works!

Locked