Skip to main content

Pie3DSeries Class

A 3D pie series in a standard chart.

Declaration

public class Pie3DSeries extends PieSeries

Remarks

Add a Pie3DSeries object to the Chart.getSeries() collection to create a 3D pie chart. The chart creates a Pie3DChartView object for the series.

Call the Chart.setView3D(value) method to tilt and rotate the 3D pie.

Refer to the following help topic for additional information: Create Standard Charts — Presentation API for Java.

Example

Create a 3D Pie Chart

The following code snippet creates a 3D pie chart, separates the slices, displays category names and values in data labels, and rotates the pie:

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 3D pie series and specify data.
            Pie3DSeries series = new Pie3DSeries();
            series.setText("Traffic Sources");
            series.setArguments(new ChartStringData(List.of("Search", "Direct", "Social", "Email")));
            series.setValues(new ChartNumericData(List.of(42.0, 28.0, 18.0, 12.0)));
            series.setExplosion(0.1f);
            chart.getSeries().add(series);

            // Color each slice differently and display category names and values in data labels.
            Pie3DChartView view = (Pie3DChartView) chart.getViews().get(0);
            view.setVaryColors(true);
            view.getDataLabels().setShowCategoryName(true);
            view.getDataLabels().setShowValue(true);

            // Tilt the pie and rotate it around the vertical axis.
            View3DOptions view3D = new View3DOptions();
            view3D.setXRotation(50);
            view3D.setYRotation(120);
            chart.setView3D(view3D);

            // 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:

 3D pie chart with separated slices created with the DevExpress Presentation API for Java

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

See Also

Pie3DSeries()

Initializes a new instance of the Pie3DSeries class.

Declaration

public Pie3DSeries()