java 如何指定 JFreeChart 图表图例的位置和布局

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4968852/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 08:51:21  来源:igfitidea点击:

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

javajfreechart

提问by ireddick

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.

我正在使用 JFreeChart 来呈现堆积面积图。默认情况下,图表图例呈现在图下方,元素水平布局。我希望图例出现在图的右侧,元素以垂直列表的形式排列。

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

这可能吗,如果可以,我该怎么做?

回答by ireddick

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

多花点时间检查 API 会给我答案:

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

回答by Vadzim

Here is the equivalent for older versions:

这是旧版本的等效项:

    StandardLegend legend = new StandardLegend();
    legend.setPreferredWidth(100);
    legend.setAnchor(Legend.EAST);
    jfreechart.setLegend(legend);