Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -96,14 +96,16 @@ def create_severity_violation_chart(df, age_group=None):
|
|
| 96 |
xaxis_tickangle=-45,
|
| 97 |
legend=dict(
|
| 98 |
orientation='v',
|
| 99 |
-
x=1,
|
| 100 |
y=1,
|
| 101 |
yanchor='top',
|
| 102 |
xanchor='left',
|
| 103 |
title="Severity Level"
|
| 104 |
),
|
| 105 |
barmode='stack',
|
| 106 |
-
|
|
|
|
|
|
|
| 107 |
xaxis=dict(
|
| 108 |
tickangle=-45,
|
| 109 |
tickfont=dict(size=9),
|
|
@@ -517,14 +519,15 @@ def main():
|
|
| 517 |
age_groups = ['All Ages', '16-25', '26-35', '36-45', '46-55', '56-65', '65+']
|
| 518 |
selected_age = st.selectbox('Select Age Group:', age_groups)
|
| 519 |
|
| 520 |
-
chart_col, desc_col = st.columns([
|
| 521 |
|
| 522 |
with chart_col:
|
| 523 |
# Create and display chart
|
| 524 |
fig, violations = create_severity_violation_chart(df, selected_age)
|
|
|
|
| 525 |
|
| 526 |
-
clicked_points = plotly_events(fig, click_event=True, override_height=600, override_width="
|
| 527 |
-
|
| 528 |
|
| 529 |
if clicked_points:
|
| 530 |
selected_violation = clicked_points[0]['x']
|
|
|
|
| 96 |
xaxis_tickangle=-45,
|
| 97 |
legend=dict(
|
| 98 |
orientation='v',
|
| 99 |
+
x=1.15,
|
| 100 |
y=1,
|
| 101 |
yanchor='top',
|
| 102 |
xanchor='left',
|
| 103 |
title="Severity Level"
|
| 104 |
),
|
| 105 |
barmode='stack',
|
| 106 |
+
height=700,
|
| 107 |
+
width=800,
|
| 108 |
+
margin=dict(t=50, b=250, l=50, r=250), # Increase bottom margin to avoid pruning
|
| 109 |
xaxis=dict(
|
| 110 |
tickangle=-45,
|
| 111 |
tickfont=dict(size=9),
|
|
|
|
| 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 clicked_points:
|
| 533 |
selected_violation = clicked_points[0]['x']
|