Ashar086 commited on
Commit
1d81696
·
verified ·
1 Parent(s): 4fd6d47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -45
app.py CHANGED
@@ -89,59 +89,59 @@ if st.button("Run Animations"):
89
 
90
  if st.session_state.initialized:
91
  # Animation 1: Patient Conditions
92
- with st.empty() as placeholder1:
93
- st.subheader("Patients by Condition")
94
- for condition, count in st.session_state.condition_counts.items():
95
- fig = create_gauge(f"Patients with {condition}", count, 200, {'x': [0, 1], 'y': [0, 1]}, 'blue')
96
- st.plotly_chart(fig, use_container_width=True)
97
- time.sleep(3) # Wait for 3 seconds before showing the next frame
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
- with st.empty() as placeholder2:
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
- time.sleep(3) # Wait for 3 seconds before showing the next frame
109
- placeholder2.empty() # Clear the previous frame
110
- st.plotly_chart(fig2, use_container_width=True)
111
- time.sleep(3) # Wait for 3 seconds before showing the next frame
112
- placeholder2.empty() # Clear the previous frame
113
- st.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
- with st.empty() as placeholder3:
118
- st.subheader("Doctor Actions")
119
- for action, count in st.session_state.doctor_actions.items():
120
- fig = create_gauge(f"Doctor Action: {action}", count, st.session_state.total_treatments, {'x': [0, 1], 'y': [0, 1]}, 'purple')
121
- st.plotly_chart(fig, use_container_width=True)
122
- time.sleep(3) # Wait for 3 seconds before showing the next frame
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
- with st.empty() as placeholder4:
128
- st.subheader("Penalties")
129
- for penalty, count in st.session_state.penalties.items():
130
- fig = create_gauge(f"Penalty: {penalty}", count, st.session_state.total_treatments // 6, {'x': [0, 1], 'y': [0, 1]}, 'red')
131
- st.plotly_chart(fig, use_container_width=True)
132
- time.sleep(3) # Wait for 3 seconds before showing the next frame
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
- with st.empty() as placeholder5:
138
- st.subheader("Patient Feedback")
139
- for fb, count in st.session_state.feedback.items():
140
- fig = create_gauge(f"Feedback: {fb}", count, st.session_state.total_treatments, {'x': [0, 1], 'y': [0, 1]}, 'blue')
141
- st.plotly_chart(fig, use_container_width=True)
142
- time.sleep(3) # Wait for 3 seconds before showing the next frame
143
- placeholder5.empty() # Clear the previous frame
144
- st.write("**End of Animations.**")
145
 
146
  # Reset session state to allow re-running the animations if needed
147
  st.session_state.initialized = False
 
89
 
90
  if st.session_state.initialized:
91
  # Animation 1: Patient Conditions
92
+ placeholder1 = st.empty()
93
+ st.subheader("Patients by Condition")
94
+ for condition, count in st.session_state.condition_counts.items():
95
+ fig = create_gauge(f"Patients with {condition}", count, 200, {'x': [0, 1], 'y': [0, 1]}, 'blue')
96
+ placeholder1.plotly_chart(fig, use_container_width=True)
97
+ time.sleep(3) # Wait for 3 seconds before showing the next frame
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
+ placeholder2 = st.empty()
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
+ placeholder2.plotly_chart(fig1, use_container_width=True)
108
+ time.sleep(3) # Wait for 3 seconds before showing the next frame
109
+ placeholder2.empty() # Clear the previous frame
110
+ placeholder2.plotly_chart(fig2, use_container_width=True)
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
+ placeholder3 = st.empty()
118
+ st.subheader("Doctor Actions")
119
+ for action, count in st.session_state.doctor_actions.items():
120
+ fig = create_gauge(f"Doctor Action: {action}", count, st.session_state.total_treatments, {'x': [0, 1], 'y': [0, 1]}, 'purple')
121
+ placeholder3.plotly_chart(fig, use_container_width=True)
122
+ time.sleep(3) # Wait for 3 seconds before showing the next frame
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
+ placeholder4 = st.empty()
128
+ st.subheader("Penalties")
129
+ for penalty, count in st.session_state.penalties.items():
130
+ fig = create_gauge(f"Penalty: {penalty}", count, st.session_state.total_treatments // 6, {'x': [0, 1], 'y': [0, 1]}, 'red')
131
+ placeholder4.plotly_chart(fig, use_container_width=True)
132
+ time.sleep(3) # Wait for 3 seconds before showing the next frame
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
+ placeholder5 = st.empty()
138
+ st.subheader("Patient Feedback")
139
+ for fb, count in st.session_state.feedback.items():
140
+ fig = create_gauge(f"Feedback: {fb}", count, st.session_state.total_treatments, {'x': [0, 1], 'y': [0, 1]}, 'blue')
141
+ placeholder5.plotly_chart(fig, use_container_width=True)
142
+ time.sleep(3) # Wait for 3 seconds before showing the next frame
143
+ placeholder5.empty() # Clear the previous frame
144
+ st.write("**End of Animations.**")
145
 
146
  # Reset session state to allow re-running the animations if needed
147
  st.session_state.initialized = False