Spaces:
Sleeping
Sleeping
Update modules/visuals.py
Browse files- modules/visuals.py +33 -24
modules/visuals.py
CHANGED
@@ -1,35 +1,44 @@
|
|
1 |
import streamlit as st
|
2 |
-
import pandas as pd
|
3 |
import plotly.express as px
|
4 |
|
5 |
-
def
|
6 |
st.subheader("π System Summary")
|
7 |
-
col1, col2, col3
|
8 |
col1.metric("Total Poles", df.shape[0])
|
9 |
-
col2.metric("Red Alerts", df[df["
|
10 |
-
col3.metric("Power Issues", df[df["
|
11 |
-
col4.metric("Offline Cameras", df[df["CameraStatus"] == "Offline"].shape[0])
|
12 |
|
13 |
-
def
|
14 |
-
st.subheader("πΊοΈ Telangana Pole Heatmap")
|
15 |
-
red_df = df[df["AlertLevel"] == "Red"]
|
16 |
fig = px.scatter_mapbox(
|
17 |
-
|
18 |
-
lat="
|
19 |
-
lon="
|
20 |
-
color="
|
21 |
-
hover_name="
|
22 |
-
zoom=6.
|
23 |
-
|
24 |
-
|
25 |
)
|
26 |
st.plotly_chart(fig, use_container_width=True)
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
def
|
33 |
-
st.
|
34 |
-
|
35 |
-
st.plotly_chart(fig)
|
|
|
1 |
import streamlit as st
|
|
|
2 |
import plotly.express as px
|
3 |
|
4 |
+
def display_dashboard(df):
|
5 |
st.subheader("π System Summary")
|
6 |
+
col1, col2, col3 = st.columns(3)
|
7 |
col1.metric("Total Poles", df.shape[0])
|
8 |
+
col2.metric("π¨ Red Alerts", df[df["Alert Level"] == "Red"].shape[0])
|
9 |
+
col3.metric("β‘ Power Issues", df[df["Power Sufficient"] == "No"].shape[0])
|
|
|
10 |
|
11 |
+
def display_map_with_alerts(df):
|
|
|
|
|
12 |
fig = px.scatter_mapbox(
|
13 |
+
df,
|
14 |
+
lat="Latitude",
|
15 |
+
lon="Longitude",
|
16 |
+
color="Alert Level",
|
17 |
+
hover_name="Pole ID",
|
18 |
+
zoom=6.2,
|
19 |
+
mapbox_style="carto-positron",
|
20 |
+
height=500
|
21 |
)
|
22 |
st.plotly_chart(fig, use_container_width=True)
|
23 |
|
24 |
+
# Blinking red poles (HTML)
|
25 |
+
red_df = df[df["Alert Level"] == "Red"]
|
26 |
+
if not red_df.empty:
|
27 |
+
st.markdown("### π΄ Blinking Red Alerts (Hub Notification)")
|
28 |
+
for _, row in red_df.iterrows():
|
29 |
+
st.markdown(
|
30 |
+
f"<div style='padding:8px;background:#ffe6e6;animation:blink 1s infinite;'>"
|
31 |
+
f"<b>{row['Pole ID']}</b> in <b>{row['Site']}</b>: {row['Anomalies']}</div>",
|
32 |
+
unsafe_allow_html=True
|
33 |
+
)
|
34 |
+
st.markdown("""
|
35 |
+
<style>
|
36 |
+
@keyframes blink {
|
37 |
+
50% { background-color: #ff4d4d; }
|
38 |
+
}
|
39 |
+
</style>
|
40 |
+
""", unsafe_allow_html=True)
|
41 |
|
42 |
+
def display_charts(df):
|
43 |
+
st.bar_chart(df.set_index("Pole ID")[["SolarGen(kWh)", "WindGen(kWh)"]])
|
44 |
+
st.scatter_chart(df.rename(columns={"Tilt(Β°)": "Tilt", "Vibration(g)": "Vibration"}).set_index("Pole ID")[["Tilt", "Vibration"]])
|
|