Sanjayraju30 commited on
Commit
9e4a9ee
Β·
verified Β·
1 Parent(s): 115c399

Update modules/visuals.py

Browse files
Files changed (1) hide show
  1. modules/visuals.py +33 -24
modules/visuals.py CHANGED
@@ -1,35 +1,44 @@
1
  import streamlit as st
2
- import pandas as pd
3
  import plotly.express as px
4
 
5
- def display_summary(df: pd.DataFrame):
6
  st.subheader("πŸ“Š System Summary")
7
- col1, col2, col3, col4 = st.columns(4)
8
  col1.metric("Total Poles", df.shape[0])
9
- col2.metric("Red Alerts", df[df["AlertLevel"] == "Red"].shape[0])
10
- col3.metric("Power Issues", df[df["PowerSufficient"] == "No"].shape[0])
11
- col4.metric("Offline Cameras", df[df["CameraStatus"] == "Offline"].shape[0])
12
 
13
- def display_tel_map(df: pd.DataFrame):
14
- st.subheader("πŸ—ΊοΈ Telangana Pole Heatmap")
15
- red_df = df[df["AlertLevel"] == "Red"]
16
  fig = px.scatter_mapbox(
17
- red_df,
18
- lat="Location_Latitude",
19
- lon="Location_Longitude",
20
- color="AlertLevel",
21
- hover_name="PoleID",
22
- zoom=6.3,
23
- height=500,
24
- mapbox_style="carto-positron"
25
  )
26
  st.plotly_chart(fig, use_container_width=True)
27
 
28
- def display_energy_trends(df: pd.DataFrame):
29
- st.subheader("βš™οΈ Solar vs Wind")
30
- st.plotly_chart(px.bar(df, x="PoleID", y=["SolarGen(kWh)", "WindGen(kWh)"], barmode="group"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
- def display_scatter(df: pd.DataFrame):
33
- st.subheader("πŸ“‰ Tilt vs Vibration")
34
- fig = px.scatter(df, x="Tilt(Β°)", y="Vibration(g)", color="AlertLevel", hover_data=["PoleID", "Site"])
35
- st.plotly_chart(fig)
 
1
  import streamlit as st
 
2
  import plotly.express as px
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_map_with_alerts(df):
 
 
12
  fig = px.scatter_mapbox(
13
+ df,
14
+ lat="Latitude",
15
+ lon="Longitude",
16
+ color="Alert Level",
17
+ hover_name="Pole ID",
18
+ zoom=6.2,
19
+ mapbox_style="carto-positron",
20
+ height=500
21
  )
22
  st.plotly_chart(fig, use_container_width=True)
23
 
24
+ # Blinking red poles (HTML)
25
+ red_df = df[df["Alert Level"] == "Red"]
26
+ if not red_df.empty:
27
+ st.markdown("### πŸ”΄ Blinking Red Alerts (Hub Notification)")
28
+ for _, row in red_df.iterrows():
29
+ st.markdown(
30
+ f"<div style='padding:8px;background:#ffe6e6;animation:blink 1s infinite;'>"
31
+ f"<b>{row['Pole ID']}</b> in <b>{row['Site']}</b>: {row['Anomalies']}</div>",
32
+ unsafe_allow_html=True
33
+ )
34
+ st.markdown("""
35
+ <style>
36
+ @keyframes blink {
37
+ 50% { background-color: #ff4d4d; }
38
+ }
39
+ </style>
40
+ """, unsafe_allow_html=True)
41
 
42
+ def display_charts(df):
43
+ st.bar_chart(df.set_index("Pole ID")[["SolarGen(kWh)", "WindGen(kWh)"]])
44
+ st.scatter_chart(df.rename(columns={"Tilt(Β°)": "Tilt", "Vibration(g)": "Vibration"}).set_index("Pole ID")[["Tilt", "Vibration"]])