Nawinkumar15's picture
Create modules/visuals.py
fa12279 verified
import streamlit as st
import seaborn as sns
import matplotlib.pyplot as plt
def display_dashboard(df):
st.subheader("πŸ“Š System Summary")
col1, col2, col3 = st.columns(3)
col1.metric("Total Poles", df.shape[0])
col2.metric("🚨 Red Alerts", df[df['AlertLevel']=="Red"].shape[0])
col3.metric("⚑ Power Issues", df[df['PowerSufficient']=="No"].shape[0])
def display_charts(df):
st.subheader("βš™οΈ Energy Generation Trends")
st.bar_chart(df.set_index("PoleID")[["SolarGen(kWh)", "WindGen(kWh)"]])
st.subheader("πŸ“‰ Tilt vs Vibration")
st.scatter_chart(df.rename(columns={"Tilt(Β°)": "Tilt", "Vibration(g)": "Vibration"}).set_index("PoleID")[["Tilt", "Vibration"]])
def display_heatmap(df):
st.subheader("πŸ”₯ Correlation Heatmap")
# Select numerical columns for correlation
numerical_cols = ["SolarGen(kWh)", "WindGen(kWh)", "Tilt(Β°)", "Vibration(g)"]
corr_matrix = df[numerical_cols].corr()
# Create heatmap using seaborn
fig, ax = plt.subplots(figsize=(8, 6))
sns.heatmap(corr_matrix, annot=True, cmap="coolwarm", vmin=-1, vmax=1, center=0, ax=ax)
plt.title("Correlation Heatmap of Pole Metrics")
# Display in Streamlit
st.pyplot(fig)