dschandra commited on
Commit
06eed18
·
verified ·
1 Parent(s): c057d2b

Create visuals.py

Browse files
Files changed (1) hide show
  1. modules/visuals.py +46 -0
modules/visuals.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import matplotlib.pyplot as plt
3
+
4
+ def display_dashboard(df):
5
+ """
6
+ Display system-wide summary metrics on the dashboard.
7
+
8
+ :param df: DataFrame containing the pole data.
9
+ """
10
+ st.subheader("📊 System Summary")
11
+
12
+ # Columns to display different metrics
13
+ col1, col2, col3 = st.columns(3)
14
+
15
+ # Total Poles
16
+ col1.metric("Total Poles", df.shape[0])
17
+
18
+ # Red Alerts
19
+ col2.metric("🚨 Red Alerts", df[df['Alert Level'] == "Red"].shape[0])
20
+
21
+ # Power Insufficiency Issues
22
+ col3.metric("⚡ Power Issues", df[df['Power Sufficient'] == "No"].shape[0])
23
+
24
+ def display_charts(df):
25
+ """
26
+ Display charts for energy generation and tilt vs vibration.
27
+
28
+ :param df: DataFrame containing the pole data.
29
+ """
30
+ st.subheader("⚙️ Energy Generation Trends")
31
+
32
+ # Plot bar chart for Solar and Wind Generation
33
+ fig, ax = plt.subplots(figsize=(10, 6))
34
+ df.set_index("Pole ID")[["Solar Gen (kWh)", "Wind Gen (kWh)"]].plot(kind="bar", ax=ax)
35
+ ax.set_ylabel("Energy Generation (kWh)")
36
+ ax.set_xlabel("Pole ID")
37
+ st.pyplot(fig)
38
+
39
+ st.subheader("📉 Tilt vs Vibration")
40
+
41
+ # Plot scatter chart for Tilt vs Vibration
42
+ fig, ax = plt.subplots(figsize=(10, 6))
43
+ ax.scatter(df["Tilt (°)"], df["Vibration (g)"], color='blue')
44
+ ax.set_xlabel("Tilt (°)")
45
+ ax.set_ylabel("Vibration (g)")
46
+ st.pyplot(fig)