How to add title in a Legend

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
LucaSirri
Posts: 15
Joined: Tue Sep 16, 2008 11:48 am

How to add title in a Legend

Post by LucaSirri » Mon Oct 06, 2008 9:50 am

Hi all,

We have two questions.. :?

1. Can I add more legend in a XYLineChart ?

2. There are a way to add title in a Legend ?

Something like :
Image

many thanks
Luca

LucaSirri
Posts: 15
Joined: Tue Sep 16, 2008 11:48 am

Post by LucaSirri » Thu Oct 16, 2008 2:55 pm

Can someone help me on this topic? :(

thanks
Luca

LucaSirri
Posts: 15
Joined: Tue Sep 16, 2008 11:48 am

Post by LucaSirri » Wed Oct 22, 2008 1:58 pm

For the legend I try to use the BlockContainer this is the code :

Code: Select all

LabelBlock labelblock = new LabelBlock("LEGEND", chartfont);
labelblock.setPadding(5D, 5D, 5D, 5D);
BlockContainer blockcontainer = new BlockContainer();
blockcontainer.add(labelblock, RectangleEdge.TOP);
BlockContainer blockcontainerReal = new BlockContainer();
LabelBlock labelblockReal = new LabelBlock("Real", chartfont);
blockcontainerReal.add( labelblockReal, RectangleEdge.TOP);
BlockContainer blockcontainerLegend = legend.getItemContainer();              
blockcontainerReal.add(blockcontainerLegend);
blockcontainer.add(blockcontainerReal);            
legend.setWrapper(blockcontainer);
This is what I get :

Image

My idea is have 2 BlockContainer one for "Real" and one for "Virtual" (see img. post # 1) and in evry BlockContainer other 2 BlockContainer one for the label an one for a part of legend...
My problem is than I can't get intems from blockcontainerLegend...

any suggest?

thanks
Luca

Locked