Resize the legend

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

Resize the legend

Post by Bernd Adam » Wed May 22, 2002 8:07 am

Hello,


Is it possible to change the size (width and height) of the legend from a chart (i.e. TimeSeriesChart)?
And if there is a possibility, can you tell me, how can I resize the legend.

Many thanks
Bernd

David Gilbert

Re: Resize the legend

Post by David Gilbert » Wed May 22, 2002 8:19 am

Hi Bernd,

The legend size is automatic...about all you can do to change the size is to change the font (setItemFont(...)) to a different size. And keep your series names short if you are trying to save space.

Apart from that, you can set the legend to null (saves space but isn't always helpful) or write a new legend class (the current one is due for an overhaul, but there is so much to do and so little time).

Regards,

DG.

Bernd Adam

Re: Resize the legend

Post by Bernd Adam » Wed May 22, 2002 9:40 am

Hi David,

thanks for your answer. But I don't know, how can I use setItemFont(...) to change the fontsize. Can you give me a short Codepart to understand this.

Many thanks
Bernd

David Gilbert

Re: Resize the legend

Post by David Gilbert » Wed May 22, 2002 12:38 pm

It would be something like:

StandardLegend legend = (StandardLegend)myChart.getLegend();
Font font = new Font("Serif", Font.PLAIN, 8);
legend.setItemFont(font);

Regards,

DG.

Bernd Adam

Re: Resize the legend

Post by Bernd Adam » Wed May 22, 2002 1:57 pm

Hi David,

thank you for your help. It works excellent.


Regards,

Bernd

Locked