Sunburst, also known as a multi-level pie chart, is ideal for visualizing multi-level hierarchical data depicted by concentric circles. The circle in the center represents the root node surrounded by the rings representing different levels of hierarchy. Rings are divided based on their relationship with the parent slice with each of them either divided equally or proportional to a value. This type of chart helps users in breaking down data into different entities for identifying and visualizing multilevel parent child relationships in different business scenarios quickly and efficiently.
Refer to the following code to add a Sunburst chart:
Java |
Copy Code |
---|---|
private static void SunburstChart() { // Initialize workbook Workbook workbook = new Workbook(); // Fetch default worksheet IWorksheet worksheet = workbook.getWorksheets().get(0); // Prepare data for chart worksheet.getRange("A1:D16") .setValue(new Object[][] { { "Region", "Subregion", "Country", "Population" }, { "Asia", "Southern", "India", 1354051854 }, { null, null, "Pakistan", 200813818 }, { null, null, "Bangladesh", 166368149 }, { null, null, "Others", 170220300 }, { null, "Eastern", "China", 1415045928 }, { null, null, "Japan", 127185332 }, { null, null, "Others", 111652273 }, { null, "South-Eastern", null, 655636576 }, { null, "Western", null, 272298399 }, { null, "Central", null, 71860465 }, { "Africa", "Eastern", null, 433643132 }, { null, "Western", null, 381980688 }, { null, "Northern", null, 237784677 }, { null, "Others", null, 234512021 }, { "Europe", null, null, 742648010 }, { "Others", null, null, 1057117703 } }); worksheet.getRange("A:D").getColumns().autoFit(); // Add Sunburst Chart IShape sunburstChartShape = worksheet.getShapes().addChart(ChartType.Sunburst, 250, 20, 360, 330); // Adding series to SeriesCollection sunburstChartShape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D16"), RowCol.Columns, true, true); // Configure Chart Title sunburstChartShape.getChart().getChartTitle().setText("World Population"); // Saving workbook to Xlsx workbook.save("32-SunburstChart.xlsx", SaveFileFormat.Xlsx); |