how to do partition of existing jfree pie Chart se

2019-07-23 03:04发布

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

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

1条回答
Viruses.
2楼-- · 2019-07-23 03:47

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:

  • 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.

  • 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().

image

查看更多
登录 后发表回答