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.Worksheets[0];
// Add a Treemap chart
int pieIdx = worksheet.Charts.Add(ChartType.Sunburst, 5, 6, 25, 12);
// Retrieve the Chart object
Chart chart = worksheet.Charts[pieIdx];
// Set the legend can be showed
chart.ShowLegend = true;
// Set the chart title name
chart.Title.Text = "Sunburst Chart";
// Add series data range
chart.NSeries.Add("D2:D16", true);
// Set category data(A2:A16 is incorrect,as hierarchical catogory)
chart.NSeries.CategoryData = "A2:C16";
// Show the DataLabels with category names
chart.NSeries[0].DataLabels.ShowCategoryName = true;
// Fill the PlotArea area with nothing
chart.PlotArea.Area.FillFormat.FillType = FillType.None;
// Save the Excel file
workbook.Save("out.xlsx"); ;