File size: 1,339 Bytes
a38657b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
931d795
a38657b
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pydeck as pdk

def display_dashboard(df):
    st.subheader("📊 System Summary")
    col1, col2, col3 = st.columns(3)
    col1.metric("Total Poles", df.shape[0])
    col2.metric("🚨 Red Alerts", df[df['Alert Level'] == "Red"].shape[0])
    col3.metric("⚡ Power Issues", df[df['Power Sufficient'] == "No"].shape[0])

def display_charts(df):
    st.subheader("⚙️ Energy Generation Trends")
    st.bar_chart(df.set_index("Pole ID")[["Solar Gen (kWh)", "Wind Gen (kWh)"]])

    st.subheader("📉 Tilt vs Vibration")
    scatter_data = df.rename(columns={"Tilt (°)": "Tilt", "Vibration (g)": "Vibration"})
    st.scatter_chart(scatter_data.set_index("Pole ID")[["Tilt", "Vibration"]])

def display_heatmap(df):
    st.subheader("🗺️ Site Heatmap - Alert Distribution")

    view = pdk.ViewState(
        latitude=16.5,
        longitude=77.5,
        zoom=6,
        pitch=40,
    )

    layer = pdk.Layer(
        "HeatmapLayer",
        data=df,
        get_position='[Longitude, Latitude]',
        get_weight="Alert Weight",  # ✅ fixed
        radiusPixels=60,
    )

    map = pdk.Deck(
        map_style="mapbox://styles/mapbox/light-v9",
        initial_view_state=view,
        layers=[layer],
        tooltip={"text": "Site: {Site}\nAlert: {Alert Level}"}
    )

    st.pydeck_chart(map)