DSatishchandra commited on
Commit
0d8780a
·
verified ·
1 Parent(s): bd8cd33

Update modules/visuals.py

Browse files
Files changed (1) hide show
  1. 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 display_heatmap(df):
6
- # Initialize the base map at a central location (around Hyderabad)
7
- center_lat = 17.385044 # Example latitude for Hyderabad
8
- center_lon = 78.486671 # Example longitude for Hyderabad
9
- map = folium.Map(location=[center_lat, center_lon], zoom_start=6)
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
- # Display the map in Streamlit
33
- folium_static(map)
34
-
35
- def folium_static(map):
36
- # This is a helper function to render Folium maps in Streamlit
37
- from streamlit.components.v1 import html
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)