Come creare un grafico Sunburst

Possibili Scenari di Utilizzo

I grafici Treemap sono utili per confrontare le proporzioni all’interno dell’istogramma, tuttavia non sono ideali per mostrare i livelli gerarchici tra le categorie più grandi e ciascun punto dati. Un grafico sunburst è molto più adatto per mostrare questo. Il grafico sunburst è ideale per visualizzare dati gerarchici. Ogni livello della gerarchia è rappresentato da un anello o cerchio, con il cerchio interno come il livello superiore della gerarchia. Un grafico sunburst senza alcun dato gerarchico (un livello di categorie) assomiglia a un grafico anulare. Tuttavia, un grafico sunburst con più livelli di categorie mostra come gli anelli esterni si riferiscono agli anelli interni. Il grafico sunburst è più efficace nel mostrare come un anello viene diviso nelle sue parti contribuenti, mentre un altro tipo di grafico gerarchico, il grafico Treemap, è ideale per confrontare le dimensioni relative.

todo:image_alt_text

Grafico sunburst

Dopo aver eseguito il codice qui sotto, vedrai il grafico Sunburst come mostrato di seguito.

todo:image_alt_text

Codice di Esempio

Il seguente codice di esempio carica il file Excel di esempio e genera il file Excel di output.

// Create an instance of Workbook
Workbook workbook = new Workbook("sunburst.xlsx");
// Access the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
// Add a SUNBURST chart
int pieIdx = worksheet.getCharts().add(ChartType.SUNBURST, 5, 6, 25, 12);
// Retrieve the Chart object
Chart chart = worksheet.getCharts().get(pieIdx);
// Set the legend can be showed
chart.setShowLegend(true);
// Set the chart title name
chart.getTitle().setText("Sunburst Chart");
// Add series data range
chart.getNSeries().add("D2:D16", true);
// Set category data(A2:A16 is incorrect,as hierarchical catogory)
chart.getNSeries().setCategoryData("A2:C16");
// Show the DataLabels with category names
chart.getNSeries().get(0).getDataLabels().setShowCategoryName(true);
// Fill the PlotArea area with nothing
chart.getPlotArea().getArea().getFillFormat().setFillType(FillType.NONE);
// Save the Excel file
workbook.save("out.xlsx");