How do you place a footer (subtitle) below the legend?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
jusepi
Posts: 16
Joined: Tue May 09, 2006 1:18 pm
Location: USA

How do you place a footer (subtitle) below the legend?

Post by jusepi » Tue Oct 17, 2006 1:59 am

I'm trying to put a footer in my charts by adding a subtitle, but even when I set the vertical alignment to BOTTOM, the legend still shows below the subtitle. Is there any work around? If not, can anyone point me in the right direction in the JFreeChart package? TIA.

jusepi
Posts: 16
Joined: Tue May 09, 2006 1:18 pm
Location: USA

Post by jusepi » Tue Oct 17, 2006 2:24 am

Actually I set the position. The vertical alignment did nothing:

Code: Select all

	footer.setPosition(RectangleEdge.BOTTOM);

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue Oct 17, 2006 10:18 am

The legend is also a chart subtitle. JFreeChart will draw the subtitles in order, from the outside of the chart working inwards (once the titles are drawn, whatever space is left is allocated to the plot).

So you need to create a chart with no legend, add your subtitle first, then add the legend.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

nice
Posts: 2
Joined: Tue Oct 17, 2006 11:24 am

Post by nice » Tue Oct 17, 2006 12:58 pm

Hello jusepi,
Can you explain about the same bit more expandedly?

Thanks & Regards,
muthu

jusepi wrote:Actually I set the position. The vertical alignment did nothing:

Code: Select all

	footer.setPosition(RectangleEdge.BOTTOM);

jusepi
Posts: 16
Joined: Tue May 09, 2006 1:18 pm
Location: USA

Post by jusepi » Tue Oct 17, 2006 8:03 pm

Nothing seemed to work until i set the legend to false when I create the chart and add the subtitle (footer) before I add the legend. The following code seems to create the same exact legend as the default:

Code: Select all

LegendTitle legend = new LegendTitle(plot);
legend.setPosition(RectangleEdge.BOTTOM);
legend.setBorder(new BlockBorder());
legend.setBackgroundPaint(Color.white);
chart.addLegend(legend);
You still need to set the footer position...

Code: Select all

footer.setPosition(RectangleEdge.BOTTOM);

Locked