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.

from aspose.cells import Workbook
from aspose.cells.charts import ChartType
from aspose.cells.drawing import FillType
# Create an instance of Workbook
workbook = Workbook("sunburst.xlsx")
# Access the first worksheet
worksheet = workbook.worksheets[0]
# Add a Treemap chart
pieIdx = worksheet.charts.add(ChartType.SUNBURST, 5, 6, 25, 12)
# Retrieve the Chart object
chart = worksheet.charts[pieIdx]
# Set the legend can be showed
chart.show_legend = True
# Set the chart title name
chart.title.text = "Sunburst Chart"
# Add series data range
chart.n_series.add("D2:D16", True)
# Set category data(A2:A16 is incorrect,as hierarchical catogory)
chart.n_series.category_data = "A2:C16"
# Show the DataLabels with category names
chart.n_series[0].data_labels.show_category_name = True
# Fill the PlotArea area with nothing
chart.plot_area.area.fill_format.fill_type = FillType.NONE
# Save the Excel file
workbook.save("out.xlsx")