Skip to main content

Pie3DChartView Class

Contains settings that apply to 3D pie series in a chart view.

Declaration

public class Pie3DChartView extends ColorfulChartView

Remarks

When you add a Pie3DSeries object to a chart, the chart creates a Pie3DChartView object for the series. Call the Chart.getViews() method to access chart views.

If the chart has no 3D view settings, the chart also creates a View3DOptions object with an X rotation of 30, a Y rotation of 0, and a perspective of 30. 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

Pie3DChartView()

Initializes a new instance of the Pie3DChartView class.

Declaration

public Pie3DChartView()

Methods

getChartType() Method

Returns the chart type of the view.

Declaration

public ChartType getChartType()

Returns

Type Description
ChartType

ChartType.PIE_3_D.

getDataLabels() Method

Returns data label settings for all series in the view.

Declaration

public IPieDataLabels getDataLabels()

Returns

Type Description
IPieDataLabels

Data label settings.

Remarks

Call the Pie3DSeries.getDataLabels() method to access data label settings for an individual series.

Refer to the following help topic for additional information: Customize Chart Data Labels — Presentation API for Java.