繁体   English   中英

jfree图表 - 如何将新项目添加到不在数据源中的图例

[英]jfree chart - how to add new item to legend that is not in data source

我正在尝试在图例中添加新项目或标签,此项目在数据集中不可用。 应该使用哪种方法将此项添加到图例?

来自jfree论坛

在条形图上添加自定义颜色的图例:

LegendItemCollection chartLegend = new LegendItemCollection();
Shape shape = new Rectangle(10, 10);
chartLegend.add(new LegendItem("label1", null, null, null, shape, Color.red));
chartLegend.add(new LegendItem("label2", null, null, null, shape, Color.blue));
plot.setFixedLegendItems(chartLegend);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM