Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -220,18 +220,29 @@ with st.sidebar.expander("Executive Dashboard Settings"):
|
|
220 |
key="dashboard_layout")
|
221 |
|
222 |
# Legend Position (common for all charts)
|
223 |
-
legend_position_options = ["top right", "top
|
224 |
-
"mid right", "mid
|
225 |
-
"bottom right", "bottom
|
226 |
legend_position = st.sidebar.selectbox("Legend Position", legend_position_options, key="legend_position")
|
227 |
|
228 |
# Map legend positions to matplotlib
|
229 |
legend_loc_map = {
|
230 |
-
"top right": "upper right", "top
|
231 |
-
"mid right": "center right", "mid
|
232 |
-
"bottom right": "lower right", "bottom
|
233 |
}
|
234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
# Brochure and Presentation Export Options
|
236 |
with st.sidebar.expander("Export Options"):
|
237 |
export_format = st.selectbox("Export Format", ["PNG", "PDF", "SVG", "HTML"], key="export_format")
|
|
|
220 |
key="dashboard_layout")
|
221 |
|
222 |
# Legend Position (common for all charts)
|
223 |
+
legend_position_options = ["top right", "top middle", "top left",
|
224 |
+
"mid right", "mid middle", "mid left",
|
225 |
+
"bottom right", "bottom middle", "bottom left"]
|
226 |
legend_position = st.sidebar.selectbox("Legend Position", legend_position_options, key="legend_position")
|
227 |
|
228 |
# Map legend positions to matplotlib
|
229 |
legend_loc_map = {
|
230 |
+
"top right": "upper right", "top middle": "upper center", "top left": "upper left",
|
231 |
+
"mid right": "center right", "mid middle": "center", "mid left": "center left",
|
232 |
+
"bottom right": "lower right", "bottom middle": "lower center", "bottom left": "lower left"
|
233 |
}
|
234 |
|
235 |
+
# Custom bbox_to_anchor values to slightly adjust the legend position
|
236 |
+
legend_bbox_map = {
|
237 |
+
"top right": (0.9, 1.1), "top middle": (0.5, 1.1), "top left": (0.1, 1.1), # Shifted higher
|
238 |
+
"mid right": (1.1, 0.5), "mid middle": (0.5, 0.6), "mid left": (-0.1, 0.5), # Adjusted for clarity
|
239 |
+
"bottom right": (0.9, -0.1), "bottom middle": (0.5, -0.1), "bottom left": (0.1, -0.1) # Shifted lower
|
240 |
+
}
|
241 |
+
|
242 |
+
# Set the legend with both loc and bbox_to_anchor to avoid overlap
|
243 |
+
ax.legend(loc=legend_loc_map[legend_position], bbox_to_anchor=legend_bbox_map[legend_position])
|
244 |
+
|
245 |
+
|
246 |
# Brochure and Presentation Export Options
|
247 |
with st.sidebar.expander("Export Options"):
|
248 |
export_format = st.selectbox("Export Format", ["PNG", "PDF", "SVG", "HTML"], key="export_format")
|