How To Create An Interactive Gantt Diagram In Python Using Plotly & Excel
Language:
In this tutorial, I will show you, how to create a Gantt Diagram in Python. The data is coming directly from an Excel file. You can do all the changes in the excel file and after running the code again you will have your updated Gantt Diagram. The Gantt Chart is interactive and will be saved as an HTML file.
import plotly.express as px import plotly import pandas as pd #import plotly.figure_factory as ff # Read Dataframe from Excel file df = pd.read_excel('tasks.xlsx') # Assign Columns to variables tasks = df['Task'] start = df['Start'] finish = df['Finish'] complete = df['Complete in %'] # Create Gantt Chart fig = px.timeline(df, x_start=start, x_end=finish, y=tasks, color=complete, title='Task Overview') # Upade/Change Layout fig.update_yaxes(autorange='reversed') fig.update_layout( title_font_size=42, font_size=18, title_font_family='Arial' ) # Interactive Gantt #fig = ff.create_gantt(df) # Save Graph and Export to HTML plotly.offline.plot(fig, filename='Task_Overview_Gantt.html')