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

前端 未结 2 2058
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 08:58

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

相关标签:
2条回答
  • 2021-02-05 09:10

    Here is the equivalent for older versions:

        StandardLegend legend = new StandardLegend();
        legend.setPreferredWidth(100);
        legend.setAnchor(Legend.EAST);
        jfreechart.setLegend(legend);
    
    0 讨论(0)
  • 2021-02-05 09:18

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

    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);
    
    0 讨论(0)
提交回复
热议问题