Prasanna1622 commited on
Commit
265edfa
·
verified ·
1 Parent(s): f58d796

Update modules/visuals.py

Browse files
Files changed (1) hide show
  1. modules/visuals.py +28 -17
modules/visuals.py CHANGED
@@ -1,24 +1,35 @@
1
- import pydeck as pdk
2
- import plotly.express as px
 
 
 
 
 
 
 
 
 
3
  import streamlit as st
 
4
 
5
- # Function to generate the dashboard summary
6
- def display_dashboard(filtered_df):
7
- st.title("VIEP Smart Poles Dashboard")
8
 
9
- # Display system summary
10
- col1, col2, col3 = st.columns(3)
11
- col1.metric("Total Poles", filtered_df.shape[0])
12
- col2.metric("Red Alerts", filtered_df[filtered_df['Alert_Level__c'] == 'Red'].shape[0])
13
- col3.metric("Power Insufficiencies", filtered_df[filtered_df['Power_Status__c'] == 'Insufficient'].shape[0])
 
 
14
 
15
- # Function to generate the alert level breakdown chart
16
- def display_charts(filtered_df):
17
- st.subheader("Alert Level Breakdown")
18
- alert_level_counts = filtered_df['Alert_Level__c'].value_counts()
19
- fig = px.pie(names=alert_level_counts.index, values=alert_level_counts.values, title="Alert Levels")
20
- st.plotly_chart(fig)
 
21
 
 
22
  # Function to generate heatmap for a given site
23
  def generate_heatmap_for_site(site_name, df):
24
  site_df = df[df['Site__c'] == site_name]
@@ -75,4 +86,4 @@ def generate_heatmap_for_site(site_name, df):
75
  initial_view_state=view_state,
76
  layers=[layer],
77
  tooltip=tooltip
78
- )
 
1
+ import pandas as pd
2
+
3
+ def display_dashboard(df: pd.DataFrame):
4
+ st.subheader("📊 System Summary")
5
+ col1, col2, col3, col4 = st.columns(4)
6
+
7
+ col1.metric("Total Poles", df.shape[0])
8
+ col2.metric("🚨 Red Alerts", df[df["Alert_Level__c"] == "Red"].shape[0])
9
+ col3.metric("⚡ Power Issues", df[df["Power_Sufficient__c"] == "No"].shape[0])
10
+ col4.metric("📷 Offline Cameras", df[df["Camera_Status__c"] == "Offline"].shape[0])
11
+
12
  import streamlit as st
13
+ import plotly.express as px
14
 
 
 
 
15
 
16
+ def display_charts(df: pd.DataFrame):
17
+ fig_energy = px.bar(
18
+ df,
19
+ x="Name",
20
+ y=["Solar_Generation__c", "Wind_Generation__c"],
21
+ )
22
+
23
 
24
+ st.subheader("🚨 Alert Level Breakdown")
25
+ fig_alerts = px.histogram(
26
+ df,
27
+ x="Alert_Level__c",
28
+ title="Number of Poles by Alert Level"
29
+ )
30
+ st.plotly_chart(fig_alerts)
31
 
32
+ import pydeck as pdk
33
  # Function to generate heatmap for a given site
34
  def generate_heatmap_for_site(site_name, df):
35
  site_df = df[df['Site__c'] == site_name]
 
86
  initial_view_state=view_state,
87
  layers=[layer],
88
  tooltip=tooltip
89
+ )