TreemapSeries Class
A series in a treemap chart.
Declaration
public class TreemapSeries extends DataSeriesExBase
Remarks
Add a TreemapSeries object to the ChartEx.getSeries() collection to create a treemap chart.
A treemap chart displays hierarchical data as nested rectangles. Each top-level category is a group of rectangles. The rectangle 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 TreemapSeries.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).
Call the setGroupLabelLayout(TreemapGroupLabelLayout value) method to specify the position of top-level category labels.
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 Treemap Chart with Group Labels in Banners
The following code snippet adds groups, items, and values to chart data cells and creates a treemap chart that displays group labels in banners, 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.
TreemapSeries series = new TreemapSeries();
chart.getSeries().add(series);
series.setArguments(new ChartDataReference(0, "A2", "B8"));
series.setValues(new ChartDataReference(0, "C2", "C8"));
series.setText("Sales");
// Display group labels in banners and category names and values in data labels.
series.setGroupLabelLayout(TreemapGroupLabelLayout.BANNER);
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:

Inherited Members
Inheritance
TreemapSeries()
Initializes a new instance of the TreemapSeries class.
Declaration
public TreemapSeries()
Methods
deepClone() Method
Creates a copy of the treemap series.
Declaration
public TreemapSeries deepClone()
Returns
| Type | Description |
|---|---|
TreemapSeries |
A copy of the treemap series. |
getChartType() Method
Returns the chart type of the series.
Declaration
public ChartExType getChartType()
Returns
| Type | Description |
|---|---|
| ChartExType |
|
getDataLabels() Method
Returns data label settings for the series.
Declaration
public ITreemapDataLabels getDataLabels()
Returns
| Type | Description |
|---|---|
| ITreemapDataLabels | Data label settings. |
Remarks
Refer to the following help topic for additional information: Customize Chart Data Labels — Presentation API for Java.
getGroupLabelLayout() Method
Returns the layout of group labels in the treemap chart.
Declaration
public TreemapGroupLabelLayout getGroupLabelLayout()
Returns
| Type | Description |
|---|---|
| TreemapGroupLabelLayout | The group label layout. |
setGroupLabelLayout(TreemapGroupLabelLayout value) Method
Sets the layout of group labels in the treemap chart.
Declaration
public void setGroupLabelLayout(TreemapGroupLabelLayout value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | TreemapGroupLabelLayout | The group label layout. |
Remarks
Group labels display names of top-level categories. The setGroupLabelLayout(value) method accepts the following values:
| Value | Description |
|---|---|
| NONE | Indicates that the treemap chart does not display group labels. |
| BANNER | Indicates that the treemap chart displays group labels in banners above group tiles. |
| OVERLAPPING | Indicates that the treemap chart displays group labels over group tiles. |