How to specify the position and layout of a JFreeChart chart legend

ireddick picture ireddick · Feb 11, 2011 · Viewed 17k times · Source

I am using JFreeChart to render a stacked area chart. By default, the chart legend is rendered below the plot with the elements laid out horizontally. I would like the legend to appear on the right of the plot with the elements laid out as a vertical list.

Is this possible and, if so, how do I do it?

Answer

ireddick picture ireddick · Feb 11, 2011

A little more time examining the API would have given me the answer:

LegendTitle legend = chart.getLegend();
legend.setPosition(RectangleEdge.RIGHT);