Data Points of Treemap and Sunburst Chart

Among other types of PowerPoint charts, there are two “hierarchical” types - Treemap and Sunburst chart (also known as Sunburst Graph, Sunburst Diagram, Radial Chart, Radial Graph or Multi Level Pie Chart). These charts display hierarchical data organized as a tree - from leaves to the top of the branch. Leaves are defined by the series data points, and each subsequent nested grouping level defined by the corresponding category. Aspose.Slides for Node.js via Java allows to format data points of Sunburst Chart and Treemap in JavaScript.

Here is a Sunburst Chart, where data in Series1 column define the leaf nodes, while other columns define hierarchical datapoints:

todo:image_alt_text

Let’s start with adding a new Sunburst chart to the presentation:

var pres = new aspose.slides.Presentation();
try {
    var chart = pres.getSlides().get_Item(0).getShapes().addChart(aspose.slides.ChartType.Sunburst, 100, 100, 450, 400);
    // ...
} finally {
    if (pres != null) {
        pres.dispose();
    }
}

If there is a need to format data points of the chart, we should use the following:

ChartDataPointLevelsManagerChartDataPointLevel classes  and ChartDataPoint.getDataPointLevels method  provide access to format data points of Treemap and Sunburst charts.  ChartDataPointLevelsManager is used for accessing multi-level categories - it represents the container of  ChartDataPointLevel objects. Basically it is a wrapper for  ChartCategoryLevelsManager with the properties added specific for data points.  ChartDataPointLevel class has two methods: getFormat and  getDataLabel which provide access to corresponding settings.

Show Data Point Value

Show value of “Leaf 4” data point:

var dataPoints = chart.getChartData().getSeries().get_Item(0).getDataPoints();
dataPoints.get_Item(3).getDataPointLevels().get_Item(0).getLabel().getDataLabelFormat().setShowValue(true);

todo:image_alt_text

Set Data Point Label and Color

Set “Branch 1” data label to show series name (“Series1”) instead of category name. Then set text color to yellow:

var branch1Label = dataPoints.get_Item(0).getDataPointLevels().get_Item(0).getLabel();
branch1Label.getDataLabelFormat().setShowCategoryName(false);
branch1Label.getDataLabelFormat().setShowSeriesName(true);
branch1Label.getDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().setFillType(java.newByte(aspose.slides.FillType.Solid));
branch1Label.getDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().getSolidFillColor().setColor(java.getStaticFieldValue("java.awt.Color", "YELLOW"));

todo:image_alt_text

Set Data Point Branch Color

Change color of “Steam 4” branch:

var pres = new aspose.slides.Presentation();
try {
    var chart = pres.getSlides().get_Item(0).getShapes().addChart(aspose.slides.ChartType.Sunburst, 100, 100, 450, 400);
    var dataPoints = chart.getChartData().getSeries().get_Item(0).getDataPoints();
    var stem4branch = dataPoints.get_Item(9).getDataPointLevels().get_Item(1);
    stem4branch.getFormat().getFill().setFillType(java.newByte(aspose.slides.FillType.Solid));
    stem4branch.getFormat().getFill().getSolidFillColor().setColor(java.getStaticFieldValue("java.awt.Color", "RED"));
    pres.save("pres.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
    if (pres != null) {
        pres.dispose();
    }
}

todo:image_alt_text

FAQ

Can I change the order (sorting) of segments in Sunburst/Treemap?

No. PowerPoint sorts segments automatically (typically by descending values, clockwise). Aspose.Slides mirrors this behavior: you can’t change the order directly; you achieve it by preprocessing the data.

How does the presentation theme affect the colors of segments and labels?

Chart colors inherit the presentation’s theme/palette unless you explicitly set fills/fonts. For consistent results, lock in solid fills and text formatting at the required levels.

Will export to PDF/PNG preserve custom branch colors and label settings?

Yes. When exporting the presentation, chart settings (fills, labels) are preserved in the output formats because Aspose.Slides renders with the chart’s formatting applied.

Can I compute the actual coordinates of a label/element for custom overlay placement on top of the chart?

Yes. After the chart layout is validated, actual X and actual Y are available for elements (for example, a DataLabel), which helps with precise positioning of overlays.