DoughnutSeries Class
A doughnut series in a standard chart.
Declaration
public class DoughnutSeries extends PieSeriesBase
Remarks
Add a DoughnutSeries object to the Chart.getSeries() collection to create a doughnut chart. The chart creates a DoughnutChartView object for the series.
Call the DoughnutSeries.setExplosion(value) method to move doughnut slices away from the chart center.
Refer to the following help topic for additional information: Create Standard Charts — Presentation API for Java.
Example
Create a Doughnut Chart
The following code snippet creates a doughnut chart, separates the slices, enlarges the doughnut hole, and displays category names and percentages in data labels:
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 doughnut series and specify data.
DoughnutSeries series = new DoughnutSeries();
series.setText("Market Share");
series.setArguments(new ChartStringData(List.of("Product A", "Product B", "Product C", "Product D")));
series.setValues(new ChartNumericData(List.of(45.0, 25.0, 18.0, 12.0)));
series.setExplosion(0.05f);
chart.getSeries().add(series);
// Enlarge the hole, rotate slices, and color each slice differently.
DoughnutChartView view = (DoughnutChartView) chart.getViews().get(0);
view.setHoleSize(50);
view.setFirstSliceAngle(90);
view.setVaryColors(true);
// Display category names and percentages in data labels.
view.getDataLabels().setShowCategoryName(true);
view.getDataLabels().setShowPercent(true);
// 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
DoughnutSeries()
Initializes a new instance of the DoughnutSeries class.
Declaration
public DoughnutSeries()
Methods
getDataLabels() Method
Returns data label settings for the series.
Declaration
public IDoughnutDataLabels getDataLabels()
Returns
| Type | Description |
|---|---|
| IDoughnutDataLabels | Data label settings. |
Remarks
Call the DoughnutChartView.getDataLabels() method to access data label settings for all series in a doughnut 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.