salesforce1 / modules /visuals.py
Sanjayraju30's picture
Create modules/visuals.py
569fbd4 verified
import streamlit as st
import plotly.express as px
import pandas as pd
def display_dashboard(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["Alert_Level__c"] == "Red"].shape[0])
col3.metric("⚑ Power Issues", df[df["Power_Sufficient__c"] == "No"].shape[0])
col4.metric("πŸ“· Offline Cameras", df[df["Camera_Status__c"] == "Offline"].shape[0])
def display_charts(df: pd.DataFrame):
st.subheader("βš™ Energy Generation")
fig_energy = px.bar(
df,
x="Name",
y=["Solar_Generation__c", "Wind_Generation__c"],
barmode="group",
title="Solar vs Wind Generation"
)
st.plotly_chart(fig_energy)
st.subheader("πŸŽ₯ Camera Status Distribution")
fig_camera = px.pie(
df,
names="Camera_Status__c",
title="Camera Status",
hole=0.4
)
st.plotly_chart(fig_camera)
st.subheader("🚨 Alert Level Breakdown")
fig_alerts = px.histogram(
df,
x="Alert_Level__c",
title="Number of Poles by Alert Level"
)
st.plotly_chart(fig_alerts)