Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -529,16 +529,16 @@ def main():
|
|
| 529 |
# clicked_points = plotly_events(fig, click_event=True, override_height=600, override_width="100%")
|
| 530 |
clicked_points = plotly_events(fig, click_event=True, override_height=600)
|
| 531 |
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
|
| 543 |
# Display statistics
|
| 544 |
if selected_age == 'All Ages':
|
|
|
|
| 529 |
# clicked_points = plotly_events(fig, click_event=True, override_height=600, override_width="100%")
|
| 530 |
clicked_points = plotly_events(fig, click_event=True, override_height=600)
|
| 531 |
|
| 532 |
+
# If a bar is clicked, update the selected violation
|
| 533 |
+
if clicked_points:
|
| 534 |
+
selected_violation = clicked_points[0]['x']
|
| 535 |
+
if st.session_state.get('selected_violation') != selected_violation:
|
| 536 |
+
st.session_state['selected_violation'] = selected_violation
|
| 537 |
+
|
| 538 |
+
# If a violation is selected, display the pie chart
|
| 539 |
+
if st.session_state.get('selected_violation'):
|
| 540 |
+
pie_chart = create_interactive_pie_chart(violations, st.session_state['selected_violation'], selected_age)
|
| 541 |
+
st.plotly_chart(pie_chart, use_container_width=True) # Dynamically render the pie chart
|
| 542 |
|
| 543 |
# Display statistics
|
| 544 |
if selected_age == 'All Ages':
|