Spaces:
Sleeping
Sleeping
Update modules/visuals.py
Browse files- modules/visuals.py +14 -3
modules/visuals.py
CHANGED
@@ -20,9 +20,12 @@ def display_map_heatmap(df, location):
|
|
20 |
st.warning("No data available for this location.")
|
21 |
return
|
22 |
|
23 |
-
# Map AlertLevel to
|
24 |
df = df.copy()
|
25 |
df["AlertColor"] = df["AlertLevel"].map({"Green": "green", "Yellow": "yellow", "Red": "red"})
|
|
|
|
|
|
|
26 |
|
27 |
# Create scatter map
|
28 |
fig = px.scatter_mapbox(
|
@@ -31,8 +34,9 @@ def display_map_heatmap(df, location):
|
|
31 |
lon="Longitude",
|
32 |
color="AlertLevel",
|
33 |
color_discrete_map={"Green": "green", "Yellow": "yellow", "Red": "red"},
|
34 |
-
|
35 |
-
|
|
|
36 |
hover_data={
|
37 |
"PoleID": True,
|
38 |
"RFID": True,
|
@@ -45,6 +49,13 @@ def display_map_heatmap(df, location):
|
|
45 |
title=f"Pole Alert Map - {location}",
|
46 |
height=600
|
47 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
fig.update_layout(
|
49 |
mapbox_style="open-street-map",
|
50 |
margin={"r":0,"t":50,"l":0,"b":0},
|
|
|
20 |
st.warning("No data available for this location.")
|
21 |
return
|
22 |
|
23 |
+
# Map AlertLevel to sizes and styles
|
24 |
df = df.copy()
|
25 |
df["AlertColor"] = df["AlertLevel"].map({"Green": "green", "Yellow": "yellow", "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["CustomClass"] = df["AlertLevel"].apply(lambda x: "blinking-red" if x == "Red" else "")
|
29 |
|
30 |
# Create scatter map
|
31 |
fig = px.scatter_mapbox(
|
|
|
34 |
lon="Longitude",
|
35 |
color="AlertLevel",
|
36 |
color_discrete_map={"Green": "green", "Yellow": "yellow", "Red": "red"},
|
37 |
+
size="MarkerSize",
|
38 |
+
size_max=25,
|
39 |
+
zoom=11,
|
40 |
hover_data={
|
41 |
"PoleID": True,
|
42 |
"RFID": True,
|
|
|
49 |
title=f"Pole Alert Map - {location}",
|
50 |
height=600
|
51 |
)
|
52 |
+
fig.update_traces(
|
53 |
+
marker=dict(
|
54 |
+
symbol=df["MarkerSymbol"],
|
55 |
+
opacity=0.8,
|
56 |
+
line=dict(width=2, color="white") if df["AlertLevel"].eq("Red").any() else None
|
57 |
+
)
|
58 |
+
)
|
59 |
fig.update_layout(
|
60 |
mapbox_style="open-street-map",
|
61 |
margin={"r":0,"t":50,"l":0,"b":0},
|