Guide · 2026-11-19

User-Generated Gantt Charts in Python: A Step-by-Step Guide

Building a Gantt chart in Python can feel straightforward until you need someone else to create or update the tasks. A static chart quickly becomes stale when dates shift, new work appears, or a teammate needs to add an item without editing code. That can turn a useful project view into a brittle script that only you can maintain. But here's the truth: you can let people enter task names, owners, and dates through a small web app, then generate the chart automatically. In this guide, I’ll show you how to build that workflow with Streamlit and Plotly. You’ll get a working example, learn how to validate task dates, and see practical ways to make the chart easier to read and maintain.

How to build a user-generated Gantt chart in Python

The simplest approach is to let people enter tasks in a Streamlit form and render them with Plotly Express. Each task needs a name, start date, finish date, and optionally an owner.

Here's why: Streamlit handles the interactive form, while Plotly draws the timeline. You can run both in one Python app without building a separate web interface.

  1. Install the libraries. In your Python environment, install Streamlit, Plotly, and pandas with pip install streamlit plotly pandas.

  2. Create a Python app. Save the code below as app.py. It stores task entries during the session, checks that finish dates follow start dates, and displays a chart when tasks exist.

  3. Run the app. Start it with streamlit run app.py. Your browser will open the task form and chart.

import pandas as pd
import plotly.express as px
import streamlit as st
from datetime import date

st.title("User-Generated Gantt Chart")

if "tasks" not in st.session_state:
    st.session_state.tasks = []

with st.form("task_form"):
    task_name = st.text_input("Task name")
    owner = st.text_input("Owner")
    start_date = st.date_input("Start date", value=date.today())
    finish_date = st.date_input("Finish date", value=date.today())
    submitted = st.form_submit_button("Add task")

if submitted:
    if not task_name.strip():
        st.error("Enter a task name.")
    elif finish_date <= start_date:
        st.error("Finish date must be after the start date.")
    else:
        st.session_state.tasks.append({
            "Task": task_name.strip(),
            "Owner": owner.strip() or "Unassigned",
            "Start": start_date,
            "Finish": finish_date,
        })
        st.success("Task added.")

if st.session_state.tasks:
    tasks_df = pd.DataFrame(st.session_state.tasks)

    chart = px.timeline(
        tasks_df,
        x_start="Start",
        x_end="Finish",
        y="Task",
        color="Owner",
        hover_data=["Owner"],
        title="Project schedule",
    )
    chart.update_yaxes(autorange="reversed")
    chart.update_layout(xaxis_title="Date", yaxis_title="Task")

    st.plotly_chart(chart, use_container_width=True)
else:
    st.info("Add a task to see the chart.")

For example, a person could add “Prepare launch plan” from May 5 to May 12, then add “Review campaign” from May 13 to May 16. Plotly turns those dates into bars on the same timeline.

Choose task fields that make the schedule useful

A chart is only as helpful as the task details behind it. Start with a small set of fields: task name, start date, finish date, and owner. Add a status or priority field only when it answers a real planning question.

For a product launch, “Write product page” and “Approve product page” work better as separate tasks. They can have different owners and dates, making overlaps and handoffs easier to spot.

You might be wondering: should each task include a progress percentage? Add one when people will update it consistently. Otherwise, the extra field can create a false sense of precision without improving decisions.

Make the Gantt chart easier to read

Color can help people distinguish owners, teams, or work types. In the example, Plotly assigns a color by owner, so a crowded schedule reveals who has several tasks at once.

Keep labels short and specific. “Prepare draft” is harder to interpret than “Draft onboarding email.” Use hover details for extra context, such as an owner or status, rather than squeezing every note onto the chart.

For a two-week marketing plan, you might show “Design landing page” and “Write launch email” as separate bars. If both are assigned to Maya during the same week, the overlap prompts a useful capacity conversation.

Validate dates and handle changing plans

Date checks prevent confusing timelines. The example rejects tasks with a finish date that falls on or before the start date. That also avoids zero-length bars that can be difficult to see.

Streamlit’s session state keeps added tasks available while the app session is active. For a longer-running team workflow, you’ll need persistent storage and clear rules for who can edit or remove entries.

Let me explain: a chart can show a schedule, but it cannot decide whether the schedule is realistic. Ask people to confirm task ownership and timing, then review overlapping work before sharing a plan.

Test and share the app with your team

Before inviting colleagues, try ordinary and unusual cases. Add two tasks with different owners, leave the owner blank, and test a finish date earlier than the start date. Confirm that the chart responds as expected.

Also consider what happens when someone refreshes the page or closes the browser. The sample keeps entries in session state, so it is intended as a starting point rather than a permanent team planning system.

If people need access from different locations, deploy the app in an environment your team can reach. Protect it appropriately, especially if task names or schedules include confidential plans.

A complementary project workflow solution: ONES.com

ONES.com brings project management and knowledge management together, while Python and Plotly handle custom Gantt chart generation. Its separate products, ONES Project and ONES Wiki, can help teams manage project work and keep supporting knowledge organized.

ONES.com product screenshot

Core capabilities

Application scenarios

Software release planning: A development team can manage issues and sprints in ONES Project, then create a Python timeline for a stakeholder meeting. The chart can highlight release milestones without replacing the team’s day-to-day workflow.

Project knowledge and execution: A project team can organize work in ONES Project and use ONES Wiki as its knowledge base. The products are sold separately, so teams can choose the product that fits their needs.

ONES.com is not a Python charting library. Think of it as a project workflow companion when the team needs structured work management alongside a custom chart.

Common challenges when building a dynamic schedule

Frequently asked questions

Can I create a Gantt chart in Python without Streamlit?

Yes. You can collect task details through another interface, then pass them to Plotly or a different visualization library. Streamlit is useful for a compact interactive app because it provides form controls and chart display in Python. If you only need a static chart, you can create task entries directly in your script and skip the form.

Does Plotly support task dependencies?

Plotly Express timelines display task bars using start and finish dates, but the example does not draw dependency arrows. You can add dependency information and build a custom visualization, or choose a charting library designed for dependency-heavy schedules. For basic plans, clear dates and ownership may be enough to communicate sequencing.

How can I keep user-created tasks after the app closes?

Session state is temporary, so it is not intended for durable team records. Connect the app to persistent storage that suits your deployment, then add access controls and a backup plan. You should also decide how people can edit or delete tasks, and how conflicting changes will be handled.

How do I show milestones in a Python Gantt chart?

A milestone is usually a single date rather than a task spanning several days. You can add a separate marker trace at the milestone date, label it with a short name, and style it differently from task bars. For example, mark “Beta release” on the date when testing is scheduled to finish.

Conclusion

You can create a user-generated Gantt chart in Python by collecting task details with Streamlit and rendering those entries with Plotly. Start with names, owners, and valid dates, then test the workflow before sharing it.

A static chart can become outdated as plans change, while a small interactive app gives people a direct way to add tasks. For ongoing team coordination, pair the custom chart with a project workflow that fits how your team plans and delivers work.