Spaces:
Sleeping
Sleeping
Update modules/visuals.py
Browse files- modules/visuals.py +11 -42
modules/visuals.py
CHANGED
@@ -1,44 +1,13 @@
|
|
1 |
import streamlit as st
|
2 |
import plotly.express as px
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
fig
|
13 |
-
|
14 |
-
lat="Latitude",
|
15 |
-
lon="Longitude",
|
16 |
-
color="Alert Level",
|
17 |
-
hover_name="Pole ID",
|
18 |
-
zoom=6.2,
|
19 |
-
mapbox_style="carto-positron",
|
20 |
-
height=500
|
21 |
-
)
|
22 |
-
st.plotly_chart(fig, use_container_width=True)
|
23 |
-
|
24 |
-
# Blinking red poles (HTML)
|
25 |
-
red_df = df[df["Alert Level"] == "Red"]
|
26 |
-
if not red_df.empty:
|
27 |
-
st.markdown("### 🔴 Blinking Red Alerts (Hub Notification)")
|
28 |
-
for _, row in red_df.iterrows():
|
29 |
-
st.markdown(
|
30 |
-
f"<div style='padding:8px;background:#ffe6e6;animation:blink 1s infinite;'>"
|
31 |
-
f"<b>{row['Pole ID']}</b> in <b>{row['Site']}</b>: {row['Anomalies']}</div>",
|
32 |
-
unsafe_allow_html=True
|
33 |
-
)
|
34 |
-
st.markdown("""
|
35 |
-
<style>
|
36 |
-
@keyframes blink {
|
37 |
-
50% { background-color: #ff4d4d; }
|
38 |
-
}
|
39 |
-
</style>
|
40 |
-
""", unsafe_allow_html=True)
|
41 |
-
|
42 |
-
def display_charts(df):
|
43 |
-
st.bar_chart(df.set_index("Pole ID")[["SolarGen(kWh)", "WindGen(kWh)"]])
|
44 |
-
st.scatter_chart(df.rename(columns={"Tilt(°)": "Tilt", "Vibration(g)": "Vibration"}).set_index("Pole ID")[["Tilt", "Vibration"]])
|
|
|
1 |
import streamlit as st
|
2 |
import plotly.express as px
|
3 |
+
import geopandas as gpd
|
4 |
+
|
5 |
+
def display_map(df):
|
6 |
+
# Assuming the data contains Latitude and Longitude fields for the poles
|
7 |
+
# Creating a GeoDataFrame
|
8 |
+
gdf = gpd.GeoDataFrame(df, geometry=gpd.points_from_xy(df['Longitude'], df['Latitude']))
|
9 |
+
# Plot the map
|
10 |
+
fig = px.scatter_mapbox(gdf, lat=gdf.geometry.y, lon=gdf.geometry.x, color='Alert Level', size_max=10,
|
11 |
+
color_continuous_scale='Reds', hover_name='Pole ID', zoom=7)
|
12 |
+
fig.update_layout(mapbox_style="open-street-map")
|
13 |
+
st.plotly_chart(fig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|