Spaces:
Sleeping
Sleeping
Create modules/visuals.py
Browse files- modules/visuals.py +42 -0
modules/visuals.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
import streamlit as st
|
4 |
+
import plotly.express as px
|
5 |
+
import pandas as pd
|
6 |
+
|
7 |
+
def display_dashboard(df: pd.DataFrame):
|
8 |
+
st.subheader("π System Summary")
|
9 |
+
col1, col2, col3, col4 = st.columns(4)
|
10 |
+
|
11 |
+
col1.metric("Total Poles", df.shape[0])
|
12 |
+
col2.metric("π¨ Red Alerts", df[df["Alert_Level__c"] == "Red"].shape[0])
|
13 |
+
col3.metric("β‘ Power Issues", df[df["Power_Sufficient__c"] == "No"].shape[0])
|
14 |
+
col4.metric("π· Offline Cameras", df[df["Camera_Status__c"] == "Offline"].shape[0])
|
15 |
+
|
16 |
+
def display_charts(df: pd.DataFrame):
|
17 |
+
st.subheader("β Energy Generation")
|
18 |
+
fig_energy = px.bar(
|
19 |
+
df,
|
20 |
+
x="Name",
|
21 |
+
y=["Solar_Generation__c", "Wind_Generation__c"],
|
22 |
+
barmode="group",
|
23 |
+
title="Solar vs Wind Generation"
|
24 |
+
)
|
25 |
+
st.plotly_chart(fig_energy)
|
26 |
+
|
27 |
+
st.subheader("π₯ Camera Status Distribution")
|
28 |
+
fig_camera = px.pie(
|
29 |
+
df,
|
30 |
+
names="Camera_Status__c",
|
31 |
+
title="Camera Status",
|
32 |
+
hole=0.4
|
33 |
+
)
|
34 |
+
st.plotly_chart(fig_camera)
|
35 |
+
|
36 |
+
st.subheader("π¨ Alert Level Breakdown")
|
37 |
+
fig_alerts = px.histogram(
|
38 |
+
df,
|
39 |
+
x="Alert_Level__c",
|
40 |
+
title="Number of Poles by Alert Level"
|
41 |
+
)
|
42 |
+
st.plotly_chart(fig_alerts)
|