Spaces:
Sleeping
Sleeping
Update modules/visuals.py
Browse files- modules/visuals.py +12 -6
modules/visuals.py
CHANGED
@@ -22,10 +22,10 @@ def display_map_heatmap(df, location):
|
|
22 |
|
23 |
# Map AlertLevel to sizes, colors, and styles
|
24 |
df = df.copy()
|
25 |
-
df["
|
26 |
df["MarkerSize"] = df["AlertLevel"].map({"Green": 10, "Yellow": 15, "Red": 20})
|
27 |
df["MarkerSymbol"] = df["AlertLevel"].map({"Green": "circle", "Yellow": "circle", "Red": "star"})
|
28 |
-
df["MarkerOpacity"] =
|
29 |
|
30 |
# Create scatter map with dark theme
|
31 |
fig = px.scatter_mapbox(
|
@@ -33,10 +33,10 @@ def display_map_heatmap(df, location):
|
|
33 |
lat="Latitude",
|
34 |
lon="Longitude",
|
35 |
color="AlertLevel",
|
36 |
-
color_discrete_map={"Green": "
|
37 |
size="MarkerSize",
|
38 |
size_max=25,
|
39 |
-
zoom=15 if location == "Hyderabad" else 11,
|
40 |
hover_data={
|
41 |
"PoleID": True,
|
42 |
"RFID": True,
|
@@ -52,14 +52,20 @@ def display_map_heatmap(df, location):
|
|
52 |
)
|
53 |
fig.update_traces(
|
54 |
marker=dict(
|
|
|
55 |
symbol=df["MarkerSymbol"],
|
56 |
opacity=df["MarkerOpacity"],
|
57 |
-
color=
|
58 |
)
|
59 |
)
|
60 |
fig.update_layout(
|
61 |
mapbox_style="carto-darkmatter",
|
62 |
margin={"r":0,"t":50,"l":0,"b":0},
|
63 |
-
showlegend=True
|
|
|
|
|
|
|
|
|
|
|
64 |
)
|
65 |
st.plotly_chart(fig, use_container_width=True)
|
|
|
22 |
|
23 |
# Map AlertLevel to sizes, colors, and styles
|
24 |
df = df.copy()
|
25 |
+
df["MarkerColor"] = df["AlertLevel"].map({"Green": "lime", "Yellow": "gold", "Red": "red"})
|
26 |
df["MarkerSize"] = df["AlertLevel"].map({"Green": 10, "Yellow": 15, "Red": 20})
|
27 |
df["MarkerSymbol"] = df["AlertLevel"].map({"Green": "circle", "Yellow": "circle", "Red": "star"})
|
28 |
+
df["MarkerOpacity"] = 0.9 # Increased opacity for visibility
|
29 |
|
30 |
# Create scatter map with dark theme
|
31 |
fig = px.scatter_mapbox(
|
|
|
33 |
lat="Latitude",
|
34 |
lon="Longitude",
|
35 |
color="AlertLevel",
|
36 |
+
color_discrete_map={"Green": "lime", "Yellow": "gold", "Red": "red"},
|
37 |
size="MarkerSize",
|
38 |
size_max=25,
|
39 |
+
zoom=15 if location == "Hyderabad" else 11,
|
40 |
hover_data={
|
41 |
"PoleID": True,
|
42 |
"RFID": True,
|
|
|
52 |
)
|
53 |
fig.update_traces(
|
54 |
marker=dict(
|
55 |
+
color=df["MarkerColor"], # Explicitly set marker color
|
56 |
symbol=df["MarkerSymbol"],
|
57 |
opacity=df["MarkerOpacity"],
|
58 |
+
line=dict(width=2, color="white") # Add white outline for contrast
|
59 |
)
|
60 |
)
|
61 |
fig.update_layout(
|
62 |
mapbox_style="carto-darkmatter",
|
63 |
margin={"r":0,"t":50,"l":0,"b":0},
|
64 |
+
showlegend=True,
|
65 |
+
legend=dict(
|
66 |
+
itemsizing="constant",
|
67 |
+
bgcolor="rgba(0, 0, 0, 0.7)",
|
68 |
+
font=dict(color="white")
|
69 |
+
)
|
70 |
)
|
71 |
st.plotly_chart(fig, use_container_width=True)
|