4.1.6 Pie2D Series

Pie Series

Pie Series displays data as sectors in circular chart. Data is composed from KEY which contains slice name and VALUE which holds quantity representing proportion of how much space slice should take. Chart's style is set either for all sectors using getStyle() and getTextStyle() methods for PieSeries object, or for each sector separately using MetaDataModel and setting it to PieSeries object when constructing PieSeries object.

1
2
3
4
5
// Sets PieSeries object, named pie, where 
//   pieModel is an instance of ChartDataModel and contains values which
//            will be shown on chart
//   meta1    is an instance of MetaDataModel and holds style settings
PieSeries pie = new PieSeries(pieModel, meta1);

Pie2D Demonstration

Figure 4.1.6.1 Pie2D Series Demonstration

View Source

Other Pie Series Properties

Radius and Inner Radius

There is a possibility to set chart's radius and inner radius. Chart's radius sets how much place chart will take -values from [0;0.5] interval should be used and inner radius - is used for constructing doughnut charts.

1
2
3
4
//setting pie radius
pie.setRadius(0.4d);
//setting inner radius
pie.setInnerRadius(0.2);

Pie radius demo

Figure 4.1.6.2 Pie2D Series Demonstration

Overall Angles

There is a feature that makes it possible to set how much space pie will take in degrees 0 - 360.

 
//setting overall angle
pie.setOverallAngle(270);
Centre Point

Centre point sets place on panel where pie chart will be. Values from [0;1] interval should be used.

 
//setting point where pie centre will be
pie.setCenterPoint(new Point2D(0.5,0.5));
Labels layout and alignment

It is possible to set layout and alignment type of pie labels: Labels Layout:

Alignment Type:

1
2
3
4
    // setting pie label layout
    pie.setLabelLayouter(PieLabelsLayouters.LABELS_INSIDE);
   // setting pie label alignment
    pie.setLabelAlignment(PieLabelAlignment.ROTATED);

Pie labels layout and alignment demo

Figure 4.1.6.3 Pie2D Series Labels Layout and Alignment Demonstration