Skip to main content

SunburstSeries Class

A series in a sunburst chart.

Declaration

public class SunburstSeries extends DataSeriesExBase

Remarks

Add a SunburstSeries object to the ChartEx.getSeries() collection to create a sunburst chart.

A sunburst chart displays hierarchical data as concentric rings. The inner ring displays top-level categories, and each outer ring displays the next category level. The segment size is proportional to the value.

To specify category levels, pass a ChartDataReference object that refers to adjacent columns of chart data cells to the SunburstSeries.setArguments(value) method. The first column contains top-level categories. To specify category levels in code, pass a ChartHierarchicalStringData object (the first list contains top-level categories).

Refer to the following help topic for additional information: Create Waterfall, Funnel, Treemap, and Other Office 2016 Charts — Presentation API for Java.

Example: Create a Sunburst Chart from Hierarchical Data

The following code snippet adds groups, items, and values to chart data cells and creates a sunburst chart with two category levels, data labels, and a title:

import java.io.*;
import java.nio.file.*;
import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] groups = { "Fruit", "Fruit", "Fruit", "Vegetables", "Vegetables", "Grain", "Grain" };
        String[] items = { "Apples", "Pears", "Plums", "Carrots", "Leeks", "Rice", "Oats" };
        double[] sales = { 42, 18, 25, 12, 30, 55, 21 };

        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.
            ChartEx chart = new ChartEx();
            chart.setWidth(presentation.getSlideSize().getWidth());
            chart.setHeight(presentation.getSlideSize().getHeight());
            slide.getShapes().add(chart);

            // Add groups, items, and values to chart data cells.
            ChartData data = chart.getData();
            data.get(0, "A1").setTextValue("Group");
            data.get(0, "B1").setTextValue("Item");
            data.get(0, "C1").setTextValue("Sales");
            for (int i = 0; i < groups.length; i++) {
                data.get(0, "A" + (i + 2)).setTextValue(groups[i]);
                data.get(0, "B" + (i + 2)).setTextValue(items[i]);
                data.get(0, "C" + (i + 2)).setNumericValue(sales[i]);
            }

            // Create a series. Two argument columns specify two category levels.
            SunburstSeries series = new SunburstSeries();
            chart.getSeries().add(series);
            series.setArguments(new ChartDataReference(0, "A2", "B8"));
            series.setValues(new ChartDataReference(0, "C2", "C8"));
            series.setText("Sales");

            // Display category names and values in data labels.
            series.getDataLabels().setShowCategoryName(true);
            series.getDataLabels().setShowValue(true);

            // Add a chart title.
            chart.setTitle(new ChartTitleEx(new TextArea("Sales by Category")));

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

 Sunburst chart with two category levels 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

Object
See Also

SunburstSeries()

Initializes a new instance of the SunburstSeries class.

Declaration

public SunburstSeries()

Methods

deepClone() Method

Creates a copy of the sunburst series.

Declaration

public SunburstSeries deepClone()

Returns

Type Description
SunburstSeries

A copy of the sunburst series.

getChartType() Method

Returns the chart type of the series.

Declaration

public ChartExType getChartType()

Returns

Type Description
ChartExType

ChartExType.SUNBURST.

getDataLabels() Method

Returns data label settings for the series.

Declaration

public ISunburstDataLabels getDataLabels()

Returns

Type Description
ISunburstDataLabels

Data label settings.

Remarks

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