简体   繁体   English

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

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

I am trying to add a new item or label in the legend, this item is not available in dataset. 我正在尝试在图例中添加新项目或标签,此项目在数据集中不可用。 Which method should be used to add this item to legend? 应该使用哪种方法将此项添加到图例?

From the jfree forum : 来自jfree论坛

Adding Legends on Bar Chart for custom colors: 在条形图上添加自定义颜色的图例:

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