4.2.3 Pie3D Series

Pie3D Series

Pie3D series uses same data model as Pie2D series, except there is a possibility to define height of each slice of pie using meta data. Chart data is composed from KEY which contains slice name and VALUE which holds quantity representing proportion of how much space slice should take.

Setting Pie3D series:

1
2
3
4
5
// Sets Pie3DSeries 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
Pie3DSeries pie = new Pie3DSeries(pieModel, meta1);

Pie3D Demonstration

Figure 4.2.3.1 Pie3D Demonstration

View Source

Other Pie3D Series Properties

Pie3D Series contains all Pie2D Series options available as well as there is a possibility to set:

Pie3D Series Height

Pie3D Series height can be set using setPieHeight() method for Pie3D Series object.

 
// setting pie height for Pie3DSeries object named pie
pie.setPieHeight(1d);
Pie3D Auto Label Layouter

Pie3D Series Labels Layout can be set to auto layout using setLabelLayouter() method for Pie3D Series object. It will be automatically calculated labels positions (outside slice or inside slice).

1
2
3
4
5
6
// setting auto label position for Pie3DSeries object named pie
pie.setLabelLayouter(Pie3DLabelsLayouters.LABELS_AUTO);
// setting auto label position with straight line for Pie3DSeries object named pie
pie.setLabelLayouter(Pie3DLabelsLayouters.LABELS_AUTO_WITH_STRAIGHT_LINE);
// setting auto label position with elbow for Pie3DSeries object named pie
pie.setLabelLayouter(Pie3DLabelsLayouters.LABELS_AUTO_WITH_ELBOW);

Pie3DSeries Auto Label Layouter

Pie3D Labels Text Alternative Color

Two colors can be set for Pie3D Series Labels Text.
It will be automatically select color, which is distinguished from the background color.
The ability to use alternative color feature for Pie3D labels text are useful when using auto label layouter.

1
2
3
4
5
6
7
8
9
// There is a problem: 
// * Pie3D one slice is in red  and area outside Pie is white.
// * Pie3D labels layouter set to auto. 
// When set alternative color for Pie3D label text, then if: 
// * label will be inside Pie3D series, text will be white color.
// * label will be outside Pie3D series, text color will be in alternative color - red.
// 
   style.getTextStyle().setColor(Color.WHITE);
   style.getTextStyle().setColor(SeriesPaintTags.ALTERNATIVE_COLOR, Color.RED);