File size: 2,576 Bytes
99747f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
from datetime import date

# Configure Streamlit page
st.set_page_config(page_title="Productivity Tracker", layout="centered")
st.markdown("<h1 style='text-align: center; color: #2C3E50;'>πŸ—“οΈ Daily Productivity Tracker</h1>", unsafe_allow_html=True)
st.markdown("<p style='text-align: center; color: gray;'>Track your tasks, working hours, and daily notes with clean summaries and visuals</p>", unsafe_allow_html=True)

# Initialize session data
if "data" not in st.session_state:
    st.session_state.data = []

# --- Input Form ---
st.markdown("### βž• Add New Entry")
with st.form("entry_form", clear_on_submit=True):
    col1, col2 = st.columns(2)
    with col1:
        task = st.text_input("πŸ“ Task Description")
    with col2:
        hours = st.number_input("⏱️ Hours Worked", min_value=0.0, step=0.5)

    notes = st.text_area("🧾 Short Notes", height=100)
    submitted = st.form_submit_button("Add Task", use_container_width=True)

# Save data
if submitted and task:
    today = date.today().strftime("%Y-%m-%d")
    st.session_state.data.append({
        "Date": today,
        "Task": task,
        "Hours": hours,
        "Notes": notes
    })
    st.success("βœ… Task added successfully!")

# Convert to DataFrame
df = pd.DataFrame(st.session_state.data)

# --- Show Data ---
if not df.empty:
    st.markdown("---")
    st.markdown("### πŸ“‹ All Logged Entries")
    st.dataframe(df, use_container_width=True)

    st.markdown("### πŸ“ˆ Productivity Overview")
    daily_summary = df.groupby("Date")["Hours"].sum().reset_index()

    fig, ax = plt.subplots(figsize=(8, 4))
    ax.plot(daily_summary["Date"], daily_summary["Hours"], marker='o', color="#3498DB", linewidth=2)
    ax.set_title("Hours Worked Per Day", fontsize=14)
    ax.set_xlabel("Date", fontsize=12)
    ax.set_ylabel("Total Hours", fontsize=12)
    ax.grid(True)
    plt.xticks(rotation=45)
    st.pyplot(fig)

    st.markdown("### πŸ“Š Summary Statistics")
    col1, col2, col3 = st.columns(3)
    with col1:
        st.metric("Total Tasks", len(df))
    with col2:
        st.metric("Total Hours", f"{df['Hours'].sum():.1f}")
    with col3:
        avg = df.groupby("Date")["Hours"].sum().mean()
        st.metric("Avg Hours/Day", f"{avg:.2f}")
else:
    st.warning("No entries yet. Start by adding a task above.")

# --- Footer ---
st.markdown("---")
st.markdown("<p style='text-align: center; color: #95A5A6;'>© 2025 Productivity Tracker | Built with ❀️ in Streamlit</p>", unsafe_allow_html=True)