DSatishchandra commited on
Commit
c675ae8
·
verified ·
1 Parent(s): 4118212

Update modules/visuals.py

Browse files
Files changed (1) hide show
  1. modules/visuals.py +8 -7
modules/visuals.py CHANGED
@@ -25,18 +25,18 @@ def display_map_heatmap(df, location):
25
 
26
  # Map AlertLevel to sizes, colors, and styles
27
  df = df.copy()
28
- df["MarkerColor"] = df["AlertLevel"].map({"Green": "chartreuse", "Yellow": "gold", "Red": "darkred"})
29
  df["MarkerSize"] = df["AlertLevel"].map({"Green": 20, "Yellow": 25, "Red": 35})
30
  df["MarkerSymbol"] = df["AlertLevel"].map({"Green": "circle", "Yellow": "circle", "Red": "star"})
31
  df["MarkerOpacity"] = 1.0 # Full opacity for maximum visibility
32
 
33
- # Create scatter map with lighter theme for testing visibility
34
  fig = px.scatter_mapbox(
35
  df,
36
  lat="Latitude",
37
  lon="Longitude",
38
  color="AlertLevel",
39
- color_discrete_map={"Green": "chartreuse", "Yellow": "gold", "Red": "darkred"},
40
  size="MarkerSize",
41
  size_max=35,
42
  zoom=15 if location == "Hyderabad" else 11,
@@ -55,20 +55,21 @@ def display_map_heatmap(df, location):
55
  )
56
  fig.update_traces(
57
  marker=dict(
58
- color=df["MarkerColor"], # Explicitly set marker color to override defaults
59
  symbol=df["MarkerSymbol"],
60
  opacity=df["MarkerOpacity"],
61
- size=df["MarkerSize"] # Ensure size is applied
62
  )
63
  )
64
  fig.update_layout(
65
- mapbox_style="open-street-map", # Temporarily switched to lighter theme
66
  margin={"r": 0, "t": 50, "l": 0, "b": 0},
67
  showlegend=True,
68
  legend=dict(
69
  itemsizing="constant",
70
  bgcolor="rgba(0, 0, 0, 0.7)",
71
- font=dict(color="white")
 
72
  )
73
  )
74
  st.plotly_chart(fig, use_container_width=True)
 
25
 
26
  # Map AlertLevel to sizes, colors, and styles
27
  df = df.copy()
28
+ df["MarkerColor"] = df["AlertLevel"].map({"Green": "green", "Yellow": "yellow", "Red": "red"})
29
  df["MarkerSize"] = df["AlertLevel"].map({"Green": 20, "Yellow": 25, "Red": 35})
30
  df["MarkerSymbol"] = df["AlertLevel"].map({"Green": "circle", "Yellow": "circle", "Red": "star"})
31
  df["MarkerOpacity"] = 1.0 # Full opacity for maximum visibility
32
 
33
+ # Create scatter map with lighter theme
34
  fig = px.scatter_mapbox(
35
  df,
36
  lat="Latitude",
37
  lon="Longitude",
38
  color="AlertLevel",
39
+ color_discrete_map={"Green": "green", "Yellow": "yellow", "Red": "red"},
40
  size="MarkerSize",
41
  size_max=35,
42
  zoom=15 if location == "Hyderabad" else 11,
 
55
  )
56
  fig.update_traces(
57
  marker=dict(
58
+ color=df["MarkerColor"], # Explicitly set marker color
59
  symbol=df["MarkerSymbol"],
60
  opacity=df["MarkerOpacity"],
61
+ size=df["MarkerSize"]
62
  )
63
  )
64
  fig.update_layout(
65
+ mapbox_style="open-street-map",
66
  margin={"r": 0, "t": 50, "l": 0, "b": 0},
67
  showlegend=True,
68
  legend=dict(
69
  itemsizing="constant",
70
  bgcolor="rgba(0, 0, 0, 0.7)",
71
+ font=dict(color="white"),
72
+ traceorder="normal" # Ensure legend order matches data
73
  )
74
  )
75
  st.plotly_chart(fig, use_container_width=True)