Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import plotly.graph_objects as go
|
| 3 |
import random
|
| 4 |
-
import time
|
| 5 |
|
| 6 |
# Initialize session state
|
| 7 |
if 'initialized' not in st.session_state:
|
|
@@ -88,60 +87,50 @@ if st.button("Run Animations"):
|
|
| 88 |
st.session_state.initialized = True
|
| 89 |
|
| 90 |
if st.session_state.initialized:
|
|
|
|
|
|
|
|
|
|
| 91 |
# Animation 1: Patient Conditions
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
placeholder1.empty() # Clear the previous frame
|
| 99 |
-
time.sleep(3) # Additional pause before moving to the next animation
|
| 100 |
|
| 101 |
# Animation 2: Treatment Metrics
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
time.sleep(3) # Wait for 3 seconds before showing the next frame
|
| 112 |
-
placeholder2.empty() # Clear the previous frame
|
| 113 |
-
placeholder2.plotly_chart(fig3, use_container_width=True)
|
| 114 |
-
time.sleep(3) # Additional pause before moving to the next animation
|
| 115 |
|
| 116 |
# Animation 3: Doctor Actions
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
placeholder3.empty() # Clear the previous frame
|
| 124 |
-
time.sleep(3) # Additional pause before moving to the next animation
|
| 125 |
|
| 126 |
# Animation 4: Penalties
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
placeholder4.empty() # Clear the previous frame
|
| 134 |
-
time.sleep(3) # Additional pause before moving to the next animation
|
| 135 |
|
| 136 |
# Animation 5: Patient Feedback
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
placeholder5.empty() # Clear the previous frame
|
| 144 |
-
st.write("**End of Animations.**")
|
| 145 |
|
| 146 |
-
|
| 147 |
-
st.session_state.initialized = False
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import plotly.graph_objects as go
|
| 3 |
import random
|
|
|
|
| 4 |
|
| 5 |
# Initialize session state
|
| 6 |
if 'initialized' not in st.session_state:
|
|
|
|
| 87 |
st.session_state.initialized = True
|
| 88 |
|
| 89 |
if st.session_state.initialized:
|
| 90 |
+
# Slider to choose the animation
|
| 91 |
+
animation_index = st.slider("Select Animation", min_value=1, max_value=5, value=1)
|
| 92 |
+
|
| 93 |
# Animation 1: Patient Conditions
|
| 94 |
+
if animation_index == 1:
|
| 95 |
+
st.subheader("Patients by Condition")
|
| 96 |
+
for condition, count in st.session_state.condition_counts.items():
|
| 97 |
+
fig = create_gauge(f"Patients with {condition}", count, 200, {'x': [0, 1], 'y': [0, 1]}, 'blue')
|
| 98 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 99 |
+
st.markdown("---")
|
|
|
|
|
|
|
| 100 |
|
| 101 |
# Animation 2: Treatment Metrics
|
| 102 |
+
elif animation_index == 2:
|
| 103 |
+
st.subheader("Treatment Metrics")
|
| 104 |
+
fig1 = create_gauge("Total Patients", 200, 200, {'x': [0, 0.5], 'y': [0, 1]}, 'green')
|
| 105 |
+
fig2 = create_gauge("Successful Treatments", st.session_state.successful_treatments, st.session_state.total_treatments, {'x': [0.5, 1], 'y': [0, 0.5]}, 'orange')
|
| 106 |
+
fig3 = create_gauge("Unsuccessful Treatments", st.session_state.unsuccessful_treatments, st.session_state.total_treatments, {'x': [0.5, 1], 'y': [0.5, 1]}, 'red')
|
| 107 |
+
st.plotly_chart(fig1, use_container_width=True)
|
| 108 |
+
st.plotly_chart(fig2, use_container_width=True)
|
| 109 |
+
st.plotly_chart(fig3, use_container_width=True)
|
| 110 |
+
st.markdown("---")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
# Animation 3: Doctor Actions
|
| 113 |
+
elif animation_index == 3:
|
| 114 |
+
st.subheader("Doctor Actions")
|
| 115 |
+
for action, count in st.session_state.doctor_actions.items():
|
| 116 |
+
fig = create_gauge(f"Doctor Action: {action}", count, st.session_state.total_treatments, {'x': [0, 1], 'y': [0, 1]}, 'purple')
|
| 117 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 118 |
+
st.markdown("---")
|
|
|
|
|
|
|
| 119 |
|
| 120 |
# Animation 4: Penalties
|
| 121 |
+
elif animation_index == 4:
|
| 122 |
+
st.subheader("Penalties")
|
| 123 |
+
for penalty, count in st.session_state.penalties.items():
|
| 124 |
+
fig = create_gauge(f"Penalty: {penalty}", count, st.session_state.total_treatments // 6, {'x': [0, 1], 'y': [0, 1]}, 'red')
|
| 125 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 126 |
+
st.markdown("---")
|
|
|
|
|
|
|
| 127 |
|
| 128 |
# Animation 5: Patient Feedback
|
| 129 |
+
elif animation_index == 5:
|
| 130 |
+
st.subheader("Patient Feedback")
|
| 131 |
+
for fb, count in st.session_state.feedback.items():
|
| 132 |
+
fig = create_gauge(f"Feedback: {fb}", count, st.session_state.total_treatments, {'x': [0, 1], 'y': [0, 1]}, 'blue')
|
| 133 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 134 |
+
st.markdown("---")
|
|
|
|
|
|
|
| 135 |
|
| 136 |
+
st.write("**End of Animations.**")
|
|
|