Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java jfree图表-如何向不在数据源中的图例添加新项_Java_Jfreechart - Fatal编程技术网

Java jfree图表-如何向不在数据源中的图例添加新项

Java jfree图表-如何向不在数据源中的图例添加新项,java,jfreechart,Java,Jfreechart,我正在尝试在图例中添加新项目或标签,此项目在数据集中不可用。应使用哪种方法将此项目添加到图例?来自: 在条形图上添加自定义颜色的图例: LegendItemCollection chartLegend = new LegendItemCollection(); Shape shape = new Rectangle(10, 10); chartLegend.add(new LegendItem("label1", null, null, null, shape, Color.red)); cha

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

来自:

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

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);