how to change thinner font in chart

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

how to change thinner font in chart

Post by kenny cheng » Wed Aug 14, 2002 7:03 am

Hi,

We have used JFreeChart for some time. We found that it display the category string with too much space.

We want to change to a thinner font like Arial Narrow. Can any one suggest the sample code to change font. Does java.awt.Font support other fonts?

Thanks.
Kenny

David Gilbert

Re: how to change thinner font in chart

Post by David Gilbert » Wed Aug 14, 2002 9:45 am

Hi Kenny,

You can use java.awt.Font for any font you have installed on your system. I usually try to stick to the Java logical fonts, since they are guaranteed to be on all systems, but there's nothing to stop you accessing other fonts by name:

CategoryPlot plot = myChart.getCategoryPlot();
CategoryAxis axis = plot.getDomainAxis();
Font font = new Font("Arial Narrow", Font.PLAIN, 10);
axis.setTickLabelFont(font);

Regards,

DG

Locked