Come creare un diagramma di Gantt
Che cos’è un diagramma di Gantt
Un diagramma di Gantt è un tipo di diagramma a barre che illustra un programma di progetto. Mostra le date di inizio e fine delle varie componenti di un progetto. Ogni attività è rappresentata da una barra, con la sua lunghezza corrispondente alla durata. I diagrammi di Gantt indicano anche le dipendenze tra le attività, permettendo ai project manager di visualizzare la sequenza in cui le attività devono essere completate. Sono ampiamente usati nella gestione di progetti per pianificare, programmare e monitorare efficacemente i progetti.
Come creare un diagramma di Gantt in Excel
Puoi creare un diagramma di Gantt in Excel seguendo questi passaggi:
-
Aggiungi alcuni dati per il diagramma di Gantt.
-
Seleziona i dati e vai su Inserisci –> Grafici –> Inserisci grafico a colonne o a barre –> Grafico a barre impilate. Nel nostro esempio, sono B1:B7, quindi inserisci un Grafico a barre impilate.
-
Seleziona il grafico,Seleziona dati->Aggiungi, imposta il Nome della serie e i Valori della serie come segue.
-
Seleziona il grafico, modifica le Etichette dell’asse orizzontale (Categoria).
-
Formatta l’asse Y, seleziona Categorie in ordine inverso.
-
Seleziona la Serie blu e imposta il Riempimento->Nessun riempimento.
-
Formatta l’asse l’Asse X, imposta i Minimo e Massimo (1/5/2019:43470, 30/1/2019:43494).
-
Aggiungi etichette dati per il grafico, ora otterrai un grafico Gantt.
Come aggiungere un grafico Gantt in Aspose.Cells per Python Excel Library
Vedi il seguente esempio di codice. Carica il file Excel di esempio contenente alcuni dati di esempio. Poi crea il grafico a barre impilate in base ai dati iniziali e imposta le proprietà rilevanti. Infine, salva il workbook in formato XLSX di output. La schermata seguente mostra il grafico Gantt creato da Aspose.Cells per Python via .NET nel file Excel di output.
Codice di Esempio
from aspose.cells import Workbook | |
from aspose.cells.charts import ChartType | |
from aspose.cells.drawing import FillType | |
# Create an instance of Workbook | |
workbook = Workbook("sample.xlsx") | |
# Access the first worksheet | |
worksheet = workbook.worksheets[0] | |
# Create BarStacked Chart | |
i = worksheet.charts.add(ChartType.BAR_STACKED, 5, 6, 20, 15) | |
# Retrieve the Chart object | |
chart = worksheet.charts[i] | |
# Set the chart title name | |
chart.title.text = "Gantt Chart" | |
# Set the chart title is Visible | |
chart.title.is_visible = True | |
# Set data range | |
chart.set_chart_data_range("B1:B6", True) | |
# Add series data range | |
chart.n_series.add("C2:C6", True) | |
# No fill for one serie | |
chart.n_series[0].area.fill_format.fill_type = FillType.NONE | |
# Set the Horizontal(Category) Axis | |
chart.n_series.category_data = "A2:A6" | |
# Reverse the Horizontal(Category) Axis | |
chart.category_axis.is_plot_order_reversed = True | |
# Set the value axis's MinValue and MaxValue | |
chart.value_axis.min_value = worksheet.cells.get("B2").value | |
chart.value_axis.max_value = worksheet.cells.get("D6").value | |
chart.plot_area.area.fill_format.fill_type = FillType.NONE | |
# Show the DataLabels | |
chart.n_series[1].data_labels.show_value = True | |
# Disable the Legend | |
chart.show_legend = False | |
# Save the result | |
workbook.save("result.xlsx") |