Skip to main content

ChartOfPieView Class

Contains settings that apply to pie of pie and bar of pie series in a chart view.

Declaration

public class ChartOfPieView extends ColorfulChartView

Remarks

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

setSplitType(ChartOfPieSplitType value) and setSplitPosition(double value) methods specify data points that the chart moves from the main pie to the secondary plot.

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

Example

Create a Bar of Pie Chart

The following code snippet creates a bar of pie chart that moves data points with values less than 15 to a secondary bar and connects the plots with series lines:

import java.io.*;
import java.nio.file.*;
import java.util.List;
import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;
import com.devexpress.system.drawing.*;

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 series for a bar of pie chart.
            ChartOfPieSeries series = new ChartOfPieSeries();
            series.setText("Sales by Region");
            series.setArguments(new ChartStringData(List.of("North", "South", "East", "West", "Online", "Partners")));
            series.setValues(new ChartNumericData(List.of(32.0, 25.0, 21.0, 12.0, 6.0, 4.0)));
            chart.getSeries().add(series);

            // Move data points with values less than 15 to a secondary bar.
            ChartOfPieView view = (ChartOfPieView) chart.getViews().get(0);
            view.setSecondChartType(ChartOfPieType.BAR);
            view.setSplitType(ChartOfPieSplitType.VALUE);
            view.setSplitPosition(15);
            view.setGapWidth(80);
            view.setVaryColors(true);

            // Draw gray series lines between the plots.
            OutlineStyle seriesLine = new OutlineStyle();
            seriesLine.setFill(new SolidFill(Color.getGray()));
            ChartElement seriesLineProperties = new ChartElement();
            seriesLineProperties.setOutlineStyle(seriesLine);
            view.setSeriesLineProperties(seriesLineProperties);

            // Display category names and values in data labels.
            view.getDataLabels().setShowCategoryName(true);
            view.getDataLabels().setShowValue(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:

 Bar of pie chart with series lines and category names in data labels 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

ChartOfPieView()

Initializes a new instance of the ChartOfPieView class.

Declaration

public ChartOfPieView()

Methods

getChartType() Method

Returns the chart type of the view.

Declaration

public ChartType getChartType()

Returns

Type Description
ChartType

ChartType.OF_PIE.

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 ChartOfPieSeries.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.

getGapWidth() Method

Returns the gap between the main pie and the secondary plot.

Declaration

public int getGapWidth()

Returns

Type Description
int

The gap width as a percentage (from 0 to 500).

getSecondChartType() Method

Returns the type of the secondary plot.

Declaration

public ChartOfPieType getSecondChartType()

Returns

Type Description
ChartOfPieType

The secondary plot type.

getSecondPlotSize() Method

Returns the size of the secondary plot as a percentage of the main pie size.

Declaration

public int getSecondPlotSize()

Returns

Type Description
int

The secondary plot size as a percentage (from 5 to 200).

getSeriesLineProperties() Method

Returns settings for series lines that connect the main pie and the secondary plot.

Declaration

public ChartElement getSeriesLineProperties()

Returns

Type Description
ChartElement

Series line settings, or null if the view does not display series lines.

getSplitPosition() Method

Returns the threshold that determines data points in the secondary plot.

Declaration

public double getSplitPosition()

Returns

Type Description
double

The split threshold.

getSplitType() Method

Returns the method that determines data points in the secondary plot.

Declaration

public ChartOfPieSplitType getSplitType()

Returns

Type Description
ChartOfPieSplitType

The split type.

setGapWidth(int value) Method

Sets the gap between the main pie and the secondary plot.

Declaration

public void setGapWidth(int value)

Parameters

Name Type Description
value int

The gap width as a percentage (from 0 to 500).

Exceptions

Type Description
ArgumentOutOfRangeException

Thrown if the value parameter is less than 0 or greater than 500.

Remarks

The value range is from 0 to 500. If you do not call the setGapWidth(value) method, the API uses 150.

setSecondChartType(ChartOfPieType value) Method

Sets the type of the secondary plot.

Declaration

public void setSecondChartType(ChartOfPieType value)

Parameters

Name Type Description
value ChartOfPieType

The secondary plot type.

Exceptions

Type Description
NullPointerException

Thrown if the value parameter is null and the chart view is in a presentation.

Remarks

The setSecondChartType(value) method accepts the following values:

Value Description
PIE Indicates that the secondary plot is a pie (pie of pie chart).
BAR Indicates that the secondary plot is a stacked bar (bar of pie chart).

If you do not call the setSecondChartType(value) method, the API uses ChartOfPieType.PIE.

setSecondPlotSize(int value) Method

Sets the size of the secondary plot as a percentage of the main pie size.

Declaration

public void setSecondPlotSize(int value)

Parameters

Name Type Description
value int

The secondary plot size as a percentage (from 5 to 200).

Exceptions

Type Description
ArgumentOutOfRangeException

Thrown if the value parameter is less than 5 or greater than 200.

Remarks

The value range is from 5 to 200. If you do not call the setSecondPlotSize(value) method, the API uses 75.

setSeriesLineProperties(ChartElement value) Method

Sets settings for series lines that connect the main pie and the secondary plot.

Declaration

public void setSeriesLineProperties(ChartElement value)

Parameters

Name Type Description
value ChartElement

Series line settings, or null to hide series lines.

Remarks

To specify the line color and width, pass a ChartElement object with outline settings to the setSeriesLineProperties(value) method.

setSplitPosition(double value) Method

Sets the threshold that determines data points in the secondary plot.

Declaration

public void setSplitPosition(double value)

Parameters

Name Type Description
value double

The split threshold.

Remarks

The split threshold meaning depends on the split type:

Split Type Data Points in the Secondary Plot
POSITION The specified number of data points from the end of the series.
VALUE Data points with values less than the threshold.
PERCENT Data points with percentages less than the threshold.

If you do not call the setSplitPosition(value) method, the API uses 1.0.

Note

The split threshold takes effect when you call the setSplitType(ChartOfPieSplitType value) method with the POSITION, VALUE, or PERCENT value.

setSplitType(ChartOfPieSplitType value) Method

Sets the method that determines data points in the secondary plot.

Declaration

public void setSplitType(ChartOfPieSplitType value)

Parameters

Name Type Description
value ChartOfPieSplitType

The split type.

Exceptions

Type Description
NullPointerException

Thrown if the value parameter is null and the chart view is in a presentation.

Remarks

The setSplitType(value) method accepts the following values:

Value Description
AUTO Indicates that the chart application determines data points in the secondary plot.
CUSTOM Indicates that the secondary plot displays a custom set of data points.
PERCENT Indicates that the secondary plot displays data points with percentages less than the split threshold.
POSITION Indicates that the secondary plot displays the specified number of data points from the end of the series.
VALUE Indicates that the secondary plot displays data points with values less than the split threshold.

If you do not call the setSplitType(value) method, the API uses ChartOfPieSplitType.AUTO.

Call the setSplitPosition(double value) method to specify the split threshold for POSITION, VALUE, and PERCENT split types.