Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -85,11 +85,11 @@ def create_severity_violation_chart(df, age_group=None):
|
|
| 85 |
|
| 86 |
)
|
| 87 |
|
| 88 |
-
fig.update_layout(
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
)
|
| 93 |
|
| 94 |
# # modified the above code because x-axis labels were partially pruned
|
| 95 |
# fig.update_layout(
|
|
@@ -110,24 +110,24 @@ def create_severity_violation_chart(df, age_group=None):
|
|
| 110 |
# dtick=1,)
|
| 111 |
# )
|
| 112 |
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
|
| 132 |
# return fig
|
| 133 |
return fig, violations
|
|
|
|
| 85 |
|
| 86 |
)
|
| 87 |
|
| 88 |
+
# fig.update_layout(
|
| 89 |
+
# xaxis_tickangle=-45,
|
| 90 |
+
# legend_title='Severity Level',
|
| 91 |
+
# barmode='stack'
|
| 92 |
+
# )
|
| 93 |
|
| 94 |
# # modified the above code because x-axis labels were partially pruned
|
| 95 |
# fig.update_layout(
|
|
|
|
| 110 |
# dtick=1,)
|
| 111 |
# )
|
| 112 |
|
| 113 |
+
fig.update_layout(
|
| 114 |
+
xaxis_tickangle=-45, # Rotate x-axis labels
|
| 115 |
+
legend=dict(
|
| 116 |
+
orientation='h', # Horizontal legend
|
| 117 |
+
y=-0.3, # Position legend below the chart
|
| 118 |
+
x=0.5, # Center legend
|
| 119 |
+
xanchor='center',
|
| 120 |
+
title="Severity Level"
|
| 121 |
+
),
|
| 122 |
+
barmode='stack',
|
| 123 |
+
margin=dict(t=50, b=200, l=50, r=50), # Adjust margins to prevent text truncation
|
| 124 |
+
xaxis=dict(
|
| 125 |
+
tickangle=-45,
|
| 126 |
+
tickfont=dict(size=10), # Slightly larger font for better readability
|
| 127 |
+
),
|
| 128 |
+
height=800, # Increase chart height to use available space
|
| 129 |
+
width=1200, # Increase chart width to use available space
|
| 130 |
+
)
|
| 131 |
|
| 132 |
# return fig
|
| 133 |
return fig, violations
|