Nawinkumar15 commited on
Commit
a19fe91
·
verified ·
1 Parent(s): 67688b4

Update modules/visuals.py

Browse files
Files changed (1) hide show
  1. modules/visuals.py +20 -12
modules/visuals.py CHANGED
@@ -1,32 +1,40 @@
1
  import streamlit as st
2
- import matplotlib.pyplot as plt
3
- import seaborn as sns
4
- import pandas as pd
5
  import pydeck as pdk
6
 
7
  def display_map(df):
8
- st.subheader("🗺️ Smart Pole Locations Map")
9
 
10
- # Basic map using st.map()
11
- st.map(df[["Latitude", "Longitude"]])
 
 
 
 
 
12
 
13
- # Optional: More detailed map using pydeck
14
  layer = pdk.Layer(
15
  "ScatterplotLayer",
16
  data=df,
17
  get_position='[Longitude, Latitude]',
18
- get_color='[255, 0, 0, 160]', # Red circles
19
- get_radius=100,
 
20
  )
21
 
22
  view_state = pdk.ViewState(
23
  latitude=df["Latitude"].mean(),
24
  longitude=df["Longitude"].mean(),
25
- zoom=6,
26
- pitch=0,
27
  )
28
 
29
- st.pydeck_chart(pdk.Deck(layers=[layer], initial_view_state=view_state))
 
 
 
 
 
 
30
 
31
 
32
  def display_dashboard(df):
 
1
  import streamlit as st
 
 
 
2
  import pydeck as pdk
3
 
4
  def display_map(df):
5
+ st.subheader("📍 Smart Poles Location Map with Alerts")
6
 
7
+ alert_colors = {
8
+ "Green": [0, 255, 0],
9
+ "Yellow": [255, 255, 0],
10
+ "Red": [255, 0, 0]
11
+ }
12
+
13
+ df["color"] = df["Alert Level"].apply(lambda x: alert_colors.get(x, [0, 0, 0]))
14
 
 
15
  layer = pdk.Layer(
16
  "ScatterplotLayer",
17
  data=df,
18
  get_position='[Longitude, Latitude]',
19
+ get_color="color",
20
+ get_radius=4,
21
+ pickable=True,
22
  )
23
 
24
  view_state = pdk.ViewState(
25
  latitude=df["Latitude"].mean(),
26
  longitude=df["Longitude"].mean(),
27
+ zoom=8,
28
+ pitch=0
29
  )
30
 
31
+ tooltip = {
32
+ "html": "<b>Pole:</b> {Pole ID} <br/><b>Site:</b> {Site} <br/><b>Alert:</b> {Alert Level} <br/><b>Anomalies:</b> {Anomalies}",
33
+ "style": {"backgroundColor": "steelblue", "color": "white"}
34
+ }
35
+
36
+ st.pydeck_chart(pdk.Deck(layers=[layer], initial_view_state=view_state, tooltip=tooltip))
37
+
38
 
39
 
40
  def display_dashboard(df):