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