PieSeries Class
A pie series in a standard chart.
Declaration
public class PieSeries extends PieSeriesBase
Remarks
Add a PieSeries object to the Chart.getSeries() collection to create a pie chart. The chart creates a PieChartView object for the series.
Pie3DSeries and ChartOfPieSeries classes derive from the PieSeries class.
Refer to the following help topic for additional information: Create Standard Charts — Presentation API for Java.
Example
Create a Pie Chart with an Exploded Slice
The following code snippet creates a pie chart, pulls the first slice out of the pie, displays category names and percentages in data labels, and applies bold text formatting to the first data label:
import java.io.*;
import java.nio.file.*;
import java.util.List;
import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;
public class Main {
public static void main(String[] args) throws Exception {
try (Presentation presentation = new Presentation()) {
// Add a blank slide.
presentation.getSlides().clear();
Slide slide = new Slide(SlideLayoutType.BLANK);
presentation.getSlides().add(slide);
// Insert a chart that fills the slide.
Chart chart = new Chart();
chart.setWidth(presentation.getSlideSize().getWidth());
chart.setHeight(presentation.getSlideSize().getHeight());
slide.getShapes().add(chart);
// Create a pie series and specify data.
PieSeries series = new PieSeries();
series.setText("Budget");
series.setArguments(new ChartStringData(List.of("Salaries", "Marketing", "Rent", "Equipment", "Travel")));
series.setValues(new ChartNumericData(List.of(48.0, 20.0, 15.0, 10.0, 7.0)));
chart.getSeries().add(series);
// Pull the first slice out of the pie.
DataPoint salaries = new DataPoint();
salaries.setExplosion(15);
series.getCustomDataPoints().put(0, salaries);
// Color each slice differently.
PieChartView view = (PieChartView) chart.getViews().get(0);
view.setVaryColors(true);
// Display category names and percentages outside slices.
IPieDataLabels dataLabels = series.getDataLabels();
dataLabels.setShowCategoryName(true);
dataLabels.setShowPercent(true);
dataLabels.setLabelPosition(PieDataLabelPosition.OUTSIDE_END);
// Apply bold text formatting to the data label of the first slice.
TextProperties boldText = new TextProperties();
boldText.setBold(true);
PieDataLabel salariesLabel = new PieDataLabel();
salariesLabel.setShowCategoryName(true);
salariesLabel.setShowPercent(true);
salariesLabel.setLabelPosition(PieDataLabelPosition.OUTSIDE_END);
salariesLabel.setTextProperties(boldText);
dataLabels.setLabel(0, salariesLabel);
// Save the presentation.
Files.createDirectories(Path.of("output"));
try (OutputStream output = Files.newOutputStream(Path.of("output", "Chart.pptx"))) {
presentation.save(output);
}
}
}
}
The following screenshot illustrates the result:

Inherited Members
Inheritance
PieSeries()
Initializes a new instance of the PieSeries class.
Declaration
public PieSeries()
Methods
getDataLabels() Method
Returns data label settings for the series.
Declaration
public IPieDataLabels getDataLabels()
Returns
| Type | Description |
|---|---|
| IPieDataLabels | Data label settings. |
Remarks
Call the PieChartView.getDataLabels() method to access data label settings for all series in a pie chart view.
Refer to the following help topic for additional information: Customize Chart Data Labels — Presentation API for Java.
getDataLabelsRange() Method
Returns a reference to cells that contain text for series data labels.
Declaration
public IChartDataReference getDataLabelsRange()
Returns
| Type | Description |
|---|---|
| IChartDataReference | A reference to the cell range, or |
setDataLabelsRange(IChartDataReference value) Method
Sets a reference to cells that contain text for series data labels.
Declaration
public void setDataLabelsRange(IChartDataReference value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | IChartDataReference | A reference to the cell range, or |
Remarks
When you assign a cell range to a series in a chart, the API calls the setShowDataLabelRange(true) method of the object that the series getDataLabels() method returns. Each data label displays the value of the cell with the same index in the range. Call the setDataLabelsRange(null) method to remove cell values from data labels.