Gantt_Chart / app.py
Umar4321's picture
Update app.py
c973454 verified
import streamlit as st
import pandas as pd
import plotly.express as px
from io import BytesIO
# Page config
st.set_page_config(page_title="Research Gantt Chart", layout="wide")
# Title and description
st.title("πŸ“Š Research Proposal Gantt Chart")
st.markdown("""
This Gantt chart outlines the 10-month timeline for your research project:
**Critical Evaluation of ASME Section VIII Rules for Nozzle Reinforcement and Placement**
Each phase is color-coded and aligned with your methodology. The timeline is shown in relative months (Month 1 to Month 10.5).
""")
# Define task data using relative months
tasks = [
{"Phase": "Literature Review", "Start": 1.0, "Finish": 2.0, "Color": "SteelBlue"},
{"Phase": "UG-37 Calculations", "Start": 2.0, "Finish": 3.0, "Color": "SlateGray"},
{"Phase": "Finite Element Analysis (FEA)", "Start": 3.0, "Finish": 6.0, "Color": "DarkOrange"},
{"Phase": "Comparative Study", "Start": 6.0, "Finish": 7.0, "Color": "Teal"},
{"Phase": "Recommendations", "Start": 7.0, "Finish": 8.0, "Color": "Olive"},
{"Phase": "Thesis & Journal Prep", "Start": 8.0, "Finish": 9.0, "Color": "Navy"},
{"Phase": "Buffer Month", "Start": 10.0, "Finish": 10.5, "Color": "LightGray"},
]
df = pd.DataFrame(tasks)
# Create Gantt chart
fig = px.timeline(
df,
x_start="Start",
x_end="Finish",
y="Phase",
color="Phase",
color_discrete_map={row["Phase"]: row["Color"] for row in tasks},
title="Gantt Chart: ASME Nozzle Reinforcement Study",
)
# Format chart
fig.update_layout(
xaxis_title="Month",
yaxis_title="Research Phase",
title_font=dict(size=22, family="Segoe UI"),
font=dict(size=14),
showlegend=False,
margin=dict(l=40, r=40, t=80, b=40),
height=650,
xaxis=dict(
tickmode="linear",
tick0=1,
dtick=1,
range=[0.5, 11],
title_font=dict(size=16),
),
)
fig.update_yaxes(autorange="reversed") # Gantt-style top-down
# Display chart
st.plotly_chart(fig, use_container_width=True)
# Export chart as HTML
st.markdown("### πŸ“₯ Download Chart as HTML")
html_buffer = BytesIO()
html_buffer.write(fig.to_html(include_plotlyjs='cdn').encode())
st.download_button(
label="Download Interactive Chart (HTML)",
data=html_buffer.getvalue(),
file_name="ASME_Research_Gantt_Chart.html",
mime="text/html"
)
st.markdown("---")
st.caption("Designed by Muhammad | Powered by Streamlit & Plotly")