Skip to main content

ChartHierarchicalStringData Class

Multi-level string chart data specified in code.

Declaration

public class ChartHierarchicalStringData extends JavaObject implements IChartArgumentData

Remarks

Pass a ChartHierarchicalStringData object to the TreemapSeries.setArguments(value) or SunburstSeries.setArguments(value) method to specify category levels in code. Other series types do not support hierarchical arguments.

Each list that you pass to the ChartHierarchicalStringData(levels) constructor is a category level. The first list contains top-level categories. Specify one item for each data point in each list.

Refer to the following help topic for additional information: Load Data into Charts — Presentation API for Java.

Example: Create a Treemap Chart with Two Category Levels

The following code snippet specifies regions and countries as two category levels and creates a treemap chart:

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

            // Specify two argument levels: regions and countries.
            ChartHierarchicalStringData arguments = new ChartHierarchicalStringData(
                    List.of("Europe", "Europe", "Europe", "Asia", "Asia"),
                    List.of("France", "Germany", "Spain", "Japan", "China"));

            // Create a treemap series with hierarchical arguments.
            TreemapSeries series = new TreemapSeries();
            series.setText("Sales");
            series.setArguments(arguments);
            series.setValues(new ChartNumericData(List.of(45.0, 60.0, 25.0, 50.0, 80.0)));
            chart.getSeries().add(series);

            // Save the presentation.
            Files.createDirectories(Path.of("output"));
            try (OutputStream output = Files.newOutputStream(Path.of("output", "Chart.pptx"))) {
                presentation.save(output);
            }
        }
    }
}

Implements

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.initFields()
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
com.devexpress.system.JavaObject
ChartHierarchicalStringData
See Also

ChartHierarchicalStringData(Iterable<String>[] levels)

Initializes a new instance of the ChartHierarchicalStringData class with the specified category levels.

Declaration

public ChartHierarchicalStringData(Iterable<String>[] levels)

Parameters

Name Type Description
levels java.lang.Iterable<java.lang.String>[]

Category levels. The first level contains top-level categories.

Exceptions

Type Description
ArgumentNullException

Thrown if the levels array or one of its items is null.

Methods

cloneArgumentData() Method

Creates a copy of the hierarchical data.

Declaration

public IChartArgumentData cloneArgumentData()

Returns

Type Description
IChartArgumentData

A copy of the hierarchical data.

getExpression(IChartDataContext context) Method

Returns the reference expression of the argument data.

Declaration

public String getExpression(IChartDataContext context)

Parameters

Name Type Description
context IChartDataContext

An object that returns sheet names for sheet indexes.

Returns

Type Description
String

null for hierarchical data.

getLevelCount() Method

Returns the number of category levels.

Declaration

public int getLevelCount()

Returns

Type Description
int

The number of category levels.

getType() Method

Returns the chart data type.

Declaration

public ChartDataType getType()

Returns

Type Description
ChartDataType

ChartDataType.HIERARCHICAL.

makeCopy() Method

Creates a copy of the hierarchical data.

Declaration

public ChartHierarchicalStringData makeCopy()

Returns

Type Description
ChartHierarchicalStringData

A copy of the hierarchical data.