Nawinkumar15 commited on
Commit
156c1e5
·
verified ·
1 Parent(s): 7b3b033

Update modules/visuals.py

Browse files
Files changed (1) hide show
  1. modules/visuals.py +18 -1
modules/visuals.py CHANGED
@@ -1,4 +1,6 @@
1
  import streamlit as st
 
 
2
 
3
  def display_dashboard(df):
4
  st.subheader("📊 System Summary")
@@ -10,5 +12,20 @@ def display_dashboard(df):
10
  def display_charts(df):
11
  st.subheader("⚙️ Energy Generation Trends")
12
  st.bar_chart(df.set_index("Pole ID")[["Solar Gen (kWh)", "Wind Gen (kWh)"]])
 
13
  st.subheader("📉 Tilt vs Vibration")
14
- st.scatter_chart(df.rename(columns={"Tilt (°)": "Tilt", "Vibration (g)": "Vibration"}).set_index("Pole ID")[["Tilt", "Vibration"]])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import matplotlib.pyplot as plt
3
+ import seaborn as sns
4
 
5
  def display_dashboard(df):
6
  st.subheader("📊 System Summary")
 
12
  def display_charts(df):
13
  st.subheader("⚙️ Energy Generation Trends")
14
  st.bar_chart(df.set_index("Pole ID")[["Solar Gen (kWh)", "Wind Gen (kWh)"]])
15
+
16
  st.subheader("📉 Tilt vs Vibration")
17
+ scatter_df = df.rename(columns={"Tilt (°)": "Tilt", "Vibration (g)": "Vibration"})
18
+ st.scatter_chart(scatter_df.set_index("Pole ID")[["Tilt", "Vibration"]])
19
+
20
+ def display_heatmap(df):
21
+ st.subheader("🌡️ Site-wise Pole Alert Heatmap")
22
+
23
+ alert_map = {"Green": 0, "Yellow": 1, "Red": 2}
24
+ df["Alert Code"] = df["Alert Level"].map(alert_map)
25
+
26
+ pivot = df.pivot(index="Site", columns="Pole ID", values="Alert Code")
27
+
28
+ fig, ax = plt.subplots(figsize=(14, 4))
29
+ sns.heatmap(pivot, annot=True, cmap="YlOrRd", linewidths=0.5, cbar_kws={'label': 'Alert Level (0=Green, 2=Red)'}, ax=ax)
30
+ st.pyplot(fig)
31
+