Adding text not related to sections into Legend in JFreeChart PieChart

后端 未结 3 598
清酒与你
清酒与你 2021-02-06 17:44

Is there a way to include some arbitrary text in the legend in a JFreeChart PieChart? I know it\'s possible to assign a PieSectionLabelGenerator in order to customi

3条回答
  •  灰色年华
    2021-02-06 18:30

    Another possibility is to create a class implementing the interface org.jfree.chart.LegendItemSource which provides all your additional legend items. Then you add your own LegendItemSource to your LegendTitle object (the only other item source is the PieChart).

    chart.getLegend().setSources(sourcesContainingTheOriginalAndYourNewOne);
    

    If you want to control where to place the legend items or in which orderm of each item source, you can override LegendTitle.

提交回复
热议问题