本文介绍了如何对同一图表上的现有jfree饼图部分进行分区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jfreechart在Spring MVC中创建一个饼图.我的要求是:

I am using Jfreechart to create a pie chart in Spring MVC. MY requirement is:

i have to create two section,FOUND and LOST on pie chart.also in,LOST section i need to create more sections representing Count of different LOST items. here

现在,我能够在图表上创建两个部分:FOUND和LOST.但我没有得到如何在同一张图上进行LOST部分的分区.我怎样才能做到这一点..请帮助

right now,i am able to create two sections on chart,FOUND and LOST.but i am not getting how to do partition of LOST section on same chart. How can i achieve this..please help

推荐答案

您可能已经开始使用 org.jfree.chart.demo.PieChartDemo1 ,作为已包含在该发行版中.不幸的是,DefaultPieDataset不支持适用于分区的子类别.

You may have started with org.jfree.chart.demo.PieChartDemo1, as the source is include in the distribution. Unfortunately, DefaultPieDataset does not support sub-categories suitable for partitioning.

以下是一种方法的概述:

Here's an outline of one approach:

  • 扩展DefaultPieDataset以包括为分区建模所需的数据,例如Set<String> lostSet<String> found,代表属于每个分区的键集.

  • Extend DefaultPieDataset to include the data required to model the partition, e.g. Set<String> lostand Set<String> found, representing the set of keys belonging to each partition.

使用调色板或相关颜色显示相关项目,例如lost的红色阴影和found的蓝色阴影.此示例说明了GanttRenderer使用饱和度变化的调色板的方法.此示例说明了使用不同色调的调色板进行XYItemRenderer的方法.自然,您需要覆盖getSectionPaint()而不是getItemPaint().

Use a palette or related colors to show related items, e.g. shades of red for lost and shades of blue for found. This example illustrates the approach for GanttRenderer using a palette of varying saturation. This example illustrates the approach for XYItemRenderer using a palette of varying hue. Naturally, you'll need to override getSectionPaint() instead of getItemPaint().

这篇关于如何对同一图表上的现有jfree饼图部分进行分区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 14:51