DSatishchandra commited on
Commit
0004ba8
·
verified ·
1 Parent(s): 6a14eeb

Update modules/visuals.py

Browse files
Files changed (1) hide show
  1. 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["AlertColor"] = df["AlertLevel"].map({"Green": "#00FF00", "Yellow": "#FFFF00", "Red": "#FF0000"}) # Green to Red gradient
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"] = df["AlertLevel"].map({"Green": 0.7, "Yellow": 0.8, "Red": 1.0})
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": "#00FF00", "Yellow": "#FFFF00", "Red": "#FF0000"},
37
  size="MarkerSize",
38
  size_max=25,
39
- zoom=15 if location == "Hyderabad" else 11, # Higher zoom for Hyderabad vacant space
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=df["AlertColor"]
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)