Spaces:
Sleeping
Sleeping
File size: 2,125 Bytes
37c591f 23479ef 37c591f 23479ef 37c591f 23479ef 37c591f 23479ef 37c591f 23479ef 37c591f 23479ef | 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 75 | import streamlit as st
import matplotlib.pyplot as plt
st.set_page_config(page_title="Atomic Habits Tracker", page_icon="π")
st.title("π Atomic Habits Tracker (Neon Edition)")
# Initialize session state
if "habits" not in st.session_state:
st.session_state.habits = {}
# Add Habit
st.subheader("β Add New Habit")
new_habit = st.text_input("Enter habit name")
if st.button("Add Habit"):
if new_habit:
st.session_state.habits[new_habit] = 0
st.success(f"Habit '{new_habit}' added!")
else:
st.warning("Please enter a habit name.")
# Mark Habit as Done
st.subheader("β
Mark Habit as Done")
if st.session_state.habits:
habit_list = list(st.session_state.habits.keys())
selected_habit = st.selectbox("Select habit", habit_list)
if st.button("Mark Done"):
st.session_state.habits[selected_habit] += 1
st.success(
f"π₯ '{selected_habit}' streak: {st.session_state.habits[selected_habit]}"
)
else:
st.info("No habits available. Add one above.")
# Show Habits
st.subheader("π Your Habits")
if st.session_state.habits:
for habit, count in st.session_state.habits.items():
st.write(f"π {habit} β π₯ {count} streak")
else:
st.write("No habits to display.")
# π Neon Graph
st.subheader("π Streak Progress Graph")
if st.session_state.habits:
habits = list(st.session_state.habits.keys())
streaks = list(st.session_state.habits.values())
fig, ax = plt.subplots()
# Neon colors
neon_colors = ["#39FF14", "#FF073A", "#00FFFF", "#FF00FF", "#FFD700"]
ax.bar(habits, streaks, color=neon_colors[:len(habits)])
ax.set_title("Habit Streaks", fontsize=14)
ax.set_xlabel("Habits")
ax.set_ylabel("Streak Count")
# Dark background for neon effect
fig.patch.set_facecolor("#0E1117")
ax.set_facecolor("#0E1117")
# Make labels white for visibility
ax.tick_params(colors="white")
ax.xaxis.label.set_color("white")
ax.yaxis.label.set_color("white")
ax.title.set_color("white")
st.pyplot(fig)
else:
st.info("Add habits to see graph.") |