File size: 2,330 Bytes
69ca979
 
 
d6bd89c
5ac19f7
d1512e5
d6bd89c
d1512e5
 
d6bd89c
d1512e5
69ca979
 
f394a2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1512e5
 
 
 
69ca979
d1512e5
69ca979
05da1e5
 
 
 
 
d1512e5
69ca979
b242679
bfbf842
 
 
 
b242679
bfbf842
 
 
 
 
 
 
 
b99384b
05da1e5
b99384b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# app.py
import streamlit as st
from salesforce_integration import fetch_poles
from modules.visuals import display_dashboard, display_charts
import plotly.express as px
import pandas as pd

# Title
st.title("πŸ“‘ VIEP Smart Poles Dashboard")

# Get data
df = fetch_poles()



#  Fetch the raw data from Salesforce
df = fetch_poles()

#  Sidebar Filters (your code should go here!)
st.sidebar.header("πŸ“ Filter Data")

selected_alert_levels = st.sidebar.multiselect(
    "Alert Level", ["Red", "Yellow", "Green"], default=["Red", "Yellow", "Green"]
)

selected_sites = st.sidebar.multiselect(
    "Site", ["Hyderabad", "Gadwal", "Kurnool", "Ballari"],
    default=["Hyderabad", "Gadwal", "Kurnool", "Ballari"]
)

selected_camera_status = st.sidebar.selectbox(
    "Camera Status", ["All", "Online", "Offline"]
)

# Apply filters to create filtered_df
filtered_df = df[
    (df["Alert_Level__c"].isin(selected_alert_levels)) &
    (df["Site__c"].isin(selected_sites))
]

if selected_camera_status != "All":
    filtered_df = filtered_df[filtered_df["Camera_Status__c"] == selected_camera_status]

# Now use filtered_df everywhere

# Show system summary
display_dashboard(filtered_df)

# Show pole table
st.subheader("πŸ“‹ Pole Table")
st.dataframe(filtered_df)

# Show charts
display_charts(filtered_df)

# Tilt vs Vibration Scatter Plot
st.subheader("πŸ“ˆ Tilt vs Vibration")
fig_tv = px.scatter(
    filtered_df,
    x="Tilt_Angle__c",
    y="Vibration_Level__c",
    color="Alert_Level__c",
    hover_name="Name",
    title="Tilt Angle vs Vibration Level"
)
st.plotly_chart(fig_tv)

# 1. System Summary (Show first)
display_dashboard(df)

# 2. Pole Table
st.subheader("πŸ“‹ Pole Table")
st.dataframe(df, use_container_width=True)

# 3. Charts
st.subheader("βš™ Energy Generation (Solar vs Wind)")
st.plotly_chart(px.bar(df, x="Name", y=["Solar_Generation__c", "Wind_Generation__c"], barmode="group"))

# 4. Charts (Energy + Alert Breakdown)
display_charts(df)

import plotly.express as df

st.subheader("πŸ“ˆ Tilt vs Vibration")

fig_tv = px.scatter(
    filtered_df,
    x="Tilt_Angle__c",         # make sure this is your column name
    y="Vibration_Level__c",    # make sure this is your column name
    color="Alert_Level__c",
    hover_name="Name",
    title="Tilt Angle vs Vibration Level"
)
st.plotly_chart(fig_tv)