Sanjayraju30's picture
Create modules/visuals.py
798d1ce verified
raw
history blame
1.3 kB
import streamlit as st
import pandas as pd
import plotly.express as px
def display_summary(df: pd.DataFrame):
st.subheader("πŸ“Š System Summary")
col1, col2, col3, col4 = st.columns(4)
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])
col4.metric("Offline Cameras", df[df["CameraStatus"] == "Offline"].shape[0])
def display_tel_map(df: pd.DataFrame):
st.subheader("πŸ—ΊοΈ Telangana Pole Heatmap")
red_df = df[df["AlertLevel"] == "Red"]
fig = px.scatter_mapbox(
red_df,
lat="Location_Latitude",
lon="Location_Longitude",
color="AlertLevel",
hover_name="PoleID",
zoom=6.3,
height=500,
mapbox_style="carto-positron"
)
st.plotly_chart(fig, use_container_width=True)
def display_energy_trends(df: pd.DataFrame):
st.subheader("βš™οΈ Solar vs Wind")
st.plotly_chart(px.bar(df, x="PoleID", y=["SolarGen(kWh)", "WindGen(kWh)"], barmode="group"))
def display_scatter(df: pd.DataFrame):
st.subheader("πŸ“‰ Tilt vs Vibration")
fig = px.scatter(df, x="Tilt(Β°)", y="Vibration(g)", color="AlertLevel", hover_data=["PoleID", "Site"])
st.plotly_chart(fig)