namdini commited on
Commit
4e1eafd
·
verified ·
1 Parent(s): dd95e26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -519,26 +519,25 @@ def main():
519
  age_groups = ['All Ages', '16-25', '26-35', '36-45', '46-55', '56-65', '65+']
520
  selected_age = st.selectbox('Select Age Group:', age_groups)
521
 
522
- chart_col, desc_col = st.columns([8, 2])
523
 
524
  with chart_col:
525
  # Create and display chart
526
  fig, violations = create_severity_violation_chart(df, selected_age)
527
- st.plotly_chart(fig, use_container_width=True) # --> for adequate space
528
 
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':
 
519
  age_groups = ['All Ages', '16-25', '26-35', '36-45', '46-55', '56-65', '65+']
520
  selected_age = st.selectbox('Select Age Group:', age_groups)
521
 
522
+ chart_col, desc_col = st.columns([7, 3])
523
 
524
  with chart_col:
525
  # Create and display chart
526
  fig, violations = create_severity_violation_chart(df, selected_age)
 
527
 
528
+ clicked_points = plotly_events(fig, click_event=True, override_height=700, override_width=800)
529
+ # clicked_points = plotly_events(fig, click_event=True, override_height=600)
530
 
531
+ # Update session state based on clicks
532
  if clicked_points:
533
  selected_violation = clicked_points[0]['x']
534
  if st.session_state.get('selected_violation') != selected_violation:
535
  st.session_state['selected_violation'] = selected_violation
536
 
537
+ # Dynamically update the pie chart if a violation is selected
538
  if st.session_state.get('selected_violation'):
539
  pie_chart = create_interactive_pie_chart(violations, st.session_state['selected_violation'], selected_age)
540
+ st.plotly_chart(pie_chart, use_container_width=True)
541
 
542
  # Display statistics
543
  if selected_age == 'All Ages':