How do I center items inside the legend?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
nimowy
Posts: 19
Joined: Fri Jan 25, 2008 10:16 pm

How do I center items inside the legend?

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

Hi,

I've been looking and looking but i haven't found the answer yet. How do i center items inside the legend?

i found how to control the alginment of the legend, but that don't center the items inside of it:
chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);


THanks for any help,

Pam

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

Post by nimowy » Mon Feb 04, 2008 5:22 pm

Hi, anyone figured out how to do this yet? I still haven't. Thanks.

klausk
Posts: 2
Joined: Fri Feb 15, 2008 10:53 am

Post by klausk » Fri Feb 15, 2008 10:54 am

I have the same problem and haven't found a solution yet.

I tried various ways with LegendWrapper and/or CenterAlignment, but nothing worked.

klausk
Posts: 2
Joined: Fri Feb 15, 2008 10:53 am

Post by klausk » Fri Feb 15, 2008 11:20 am

I've found a solution in the thread "Exctracting and showing only Legend".

I create a centered legend at the bottom of my chart

Code: Select all

chart.removeLegend();
LegendTitle legendTitle = new LegendTitle(plot,
	new ColumnArrangement(HorizontalAlignment.LEFT, VerticalAlignment.CENTER, 0, 0),
	new ColumnArrangement(HorizontalAlignment.LEFT, VerticalAlignment.CENTER, 0, 0));
legendTitle.setPosition(RectangleEdge.BOTTOM);
chart.addLegend(legendTitle); 

Locked