Position of legend

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

Position of legend

Post by Lou Tylee » Wed Jan 15, 2003 10:03 pm

The default legend position is a horizontal layout at the bottom of the plot. Is there a way to change this to a vertical layout at the right of the plot?

Don Mitchell

Re: Position of legend

Post by Don Mitchell » Thu Jan 16, 2003 1:49 am

Lou,

If you get the Legend from the JFreeChart, you can change it's position using the setAnchor() method. Something like this:

JFreeChart chart;
...
Legend legend = chart.getLegend();
legend.setAnchor(Legend.EAST);

Use NORTH, SOUTH, WEST from the Legend class to choose other positions on the chart.

Don

Locked