Align Legend

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
jorgens
Posts: 1
Joined: Fri Jun 30, 2006 8:34 am

Align Legend

Post by jorgens » Fri Jun 30, 2006 8:39 am

Hi There,

I am trying to align the legend below a XY Linegraph with the extents of the axis of the graph. Currently my code looks like this:

Code: Select all

LegendTitle legend = new LegendTitle(chart.getPlot());
	        
	        BlockContainer wrapper = new BlockContainer(new BorderArrangement());
	        wrapper.setBorder(new BlockBorder(1.0, 1.0, 1.0, 1.0));
	       
	        BlockContainer items = legend.getItemContainer();
	        items.setPadding(2, 10, 5, 2);
	        wrapper.add(items);
	        legend.setWrapper(wrapper);
	        
	        legend.setPosition(RectangleEdge.BOTTOM);
	        legend.setHorizontalAlignment(HorizontalAlignment.CENTER);
	        chart.addSubtitle(legend);
setting padding or margin does not seem to work, since the Legenditems somehow stay fixed and do not wrap dynamically based on the space given by the blockcontainer.

How can I set position and extent of the Legend?

Thanks in advance.

nimowy
Posts: 19
Joined: Fri Jan 25, 2008 10:16 pm

Post by nimowy » Fri Feb 01, 2008 4:04 pm

I am also wondering this...

Locked