Nawinkumar15 commited on
Commit
a38657b
·
verified ·
1 Parent(s): d1b2606

Create modules/visuals.py

Browse files
Files changed (1) hide show
  1. modules/visuals.py +44 -0
modules/visuals.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pydeck as pdk
3
+
4
+ def display_dashboard(df):
5
+ st.subheader("📊 System Summary")
6
+ col1, col2, col3 = st.columns(3)
7
+ col1.metric("Total Poles", df.shape[0])
8
+ col2.metric("🚨 Red Alerts", df[df['Alert Level'] == "Red"].shape[0])
9
+ col3.metric("⚡ Power Issues", df[df['Power Sufficient'] == "No"].shape[0])
10
+
11
+ def display_charts(df):
12
+ st.subheader("⚙️ Energy Generation Trends")
13
+ st.bar_chart(df.set_index("Pole ID")[["Solar Gen (kWh)", "Wind Gen (kWh)"]])
14
+
15
+ st.subheader("📉 Tilt vs Vibration")
16
+ scatter_data = df.rename(columns={"Tilt (°)": "Tilt", "Vibration (g)": "Vibration"})
17
+ st.scatter_chart(scatter_data.set_index("Pole ID")[["Tilt", "Vibration"]])
18
+
19
+ def display_heatmap(df):
20
+ st.subheader("🗺️ Site Heatmap - Alert Distribution")
21
+
22
+ view = pdk.ViewState(
23
+ latitude=16.5,
24
+ longitude=77.5,
25
+ zoom=6,
26
+ pitch=40,
27
+ )
28
+
29
+ layer = pdk.Layer(
30
+ "HeatmapLayer",
31
+ data=df,
32
+ get_position='[Longitude, Latitude]',
33
+ get_weight='1',
34
+ radiusPixels=60,
35
+ )
36
+
37
+ map = pdk.Deck(
38
+ map_style="mapbox://styles/mapbox/light-v9",
39
+ initial_view_state=view,
40
+ layers=[layer],
41
+ tooltip={"text": "Site: {Site}\nAlert: {Alert Level}"}
42
+ )
43
+
44
+ st.pydeck_chart(map)