Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -111,14 +111,19 @@ def main():
|
|
| 111 |
# Initial Zoom Level
|
| 112 |
zoom_level = st.sidebar.slider("Initial Zoom Level", min_value=1, max_value=20, value=3)
|
| 113 |
|
| 114 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
if color_mode == "Color Scale" and color_column:
|
| 116 |
# Color Scale Mode with a selected color column
|
| 117 |
color_param = color_column
|
| 118 |
color_discrete_sequence = None
|
| 119 |
color_continuous_scale = "Viridis"
|
| 120 |
elif color_mode == "Color Scale" and not color_column:
|
| 121 |
-
# Color Scale Mode without a selected color column
|
| 122 |
color_param = None
|
| 123 |
color_discrete_sequence = "Viridis"
|
| 124 |
color_continuous_scale = None
|
|
@@ -128,7 +133,7 @@ def main():
|
|
| 128 |
color_discrete_sequence = [color]
|
| 129 |
color_continuous_scale = None
|
| 130 |
|
| 131 |
-
# Create the map
|
| 132 |
if size_col:
|
| 133 |
fig = px.scatter_mapbox(
|
| 134 |
valid_df,
|
|
@@ -162,9 +167,16 @@ def main():
|
|
| 162 |
title="Interactive Map"
|
| 163 |
)
|
| 164 |
if color_mode == "Single Color":
|
| 165 |
-
# Update marker color directly
|
| 166 |
fig.update_traces(marker=dict(color=color))
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
# Update layout for better aesthetics
|
| 169 |
fig.update_layout(
|
| 170 |
margin={"r":0,"t":30,"l":0,"b":0},
|
|
|
|
| 111 |
# Initial Zoom Level
|
| 112 |
zoom_level = st.sidebar.slider("Initial Zoom Level", min_value=1, max_value=20, value=3)
|
| 113 |
|
| 114 |
+
# Validate Color Scale Selection
|
| 115 |
+
if color_mode == "Color Scale" and not color_column:
|
| 116 |
+
st.sidebar.warning("Please select a column for color scale.")
|
| 117 |
+
st.stop() # Prevent further execution until a column is selected
|
| 118 |
+
|
| 119 |
+
# Determine color parameters based on color mode
|
| 120 |
if color_mode == "Color Scale" and color_column:
|
| 121 |
# Color Scale Mode with a selected color column
|
| 122 |
color_param = color_column
|
| 123 |
color_discrete_sequence = None
|
| 124 |
color_continuous_scale = "Viridis"
|
| 125 |
elif color_mode == "Color Scale" and not color_column:
|
| 126 |
+
# Color Scale Mode without a selected color column (handled above)
|
| 127 |
color_param = None
|
| 128 |
color_discrete_sequence = "Viridis"
|
| 129 |
color_continuous_scale = None
|
|
|
|
| 133 |
color_discrete_sequence = [color]
|
| 134 |
color_continuous_scale = None
|
| 135 |
|
| 136 |
+
# Create the map based on size and color settings
|
| 137 |
if size_col:
|
| 138 |
fig = px.scatter_mapbox(
|
| 139 |
valid_df,
|
|
|
|
| 167 |
title="Interactive Map"
|
| 168 |
)
|
| 169 |
if color_mode == "Single Color":
|
| 170 |
+
# Update marker color directly for Single Color Mode
|
| 171 |
fig.update_traces(marker=dict(color=color))
|
| 172 |
+
else:
|
| 173 |
+
# If no color is set, ensure default color scale
|
| 174 |
+
pass
|
| 175 |
+
|
| 176 |
+
# Apply default bubble size when no size column is selected
|
| 177 |
+
if not size_col:
|
| 178 |
+
fig.update_traces(marker=dict(size=default_size))
|
| 179 |
+
|
| 180 |
# Update layout for better aesthetics
|
| 181 |
fig.update_layout(
|
| 182 |
margin={"r":0,"t":30,"l":0,"b":0},
|