Spaces:
Build error
Build error
Update modules/visuals.py
Browse files- modules/visuals.py +12 -35
modules/visuals.py
CHANGED
|
@@ -1,38 +1,15 @@
|
|
| 1 |
-
import folium
|
| 2 |
-
from folium.plugins import HeatMap
|
| 3 |
import streamlit as st
|
|
|
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
# Add heatmap layer
|
| 12 |
-
heat_data = []
|
| 13 |
-
for index, row in df.iterrows():
|
| 14 |
-
lat = row["Latitude"]
|
| 15 |
-
lon = row["Longitude"]
|
| 16 |
-
alert = row["Alert Level"]
|
| 17 |
-
|
| 18 |
-
# Color mapping for heatmap intensity based on alert level
|
| 19 |
-
if alert == "Green":
|
| 20 |
-
color = [0, 255, 0] # Green
|
| 21 |
-
elif alert == "Yellow":
|
| 22 |
-
color = [255, 255, 0] # Yellow
|
| 23 |
-
elif alert == "Red":
|
| 24 |
-
color = [255, 0, 0] # Red
|
| 25 |
-
|
| 26 |
-
# Add data to the heatmap layer (latitude, longitude, intensity)
|
| 27 |
-
heat_data.append([lat, lon, 1 if alert == "Red" else 0.5 if alert == "Yellow" else 0.1])
|
| 28 |
-
|
| 29 |
-
# Create HeatMap with data
|
| 30 |
-
HeatMap(heat_data).add_to(map)
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
html(map._repr_html_(), width=725, height=500)
|
|
|
|
|
|
|
|
|
|
| 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 = st.columns(2)
|
| 7 |
+
col1.metric("Total Poles", df.shape[0])
|
| 8 |
+
col2.metric("🚨 Red Alerts", df[df['Alert Level'] == "Red"].shape[0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
def display_heatmap(df):
|
| 11 |
+
st.subheader("🌡️ Fault Heatmap")
|
| 12 |
+
# Grouping the data by area (simplified) and plotting the heatmap
|
| 13 |
+
heatmap_data = df.groupby(['Pole ID', 'Alert Level']).size().unstack(fill_value=0)
|
| 14 |
+
fig = px.imshow(heatmap_data, title="Fault Distribution")
|
| 15 |
+
st.plotly_chart(fig)
|
|
|