Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -290,7 +290,7 @@ st.sidebar.markdown('</div>', unsafe_allow_html=True)
|
|
| 290 |
import streamlit as st
|
| 291 |
import os
|
| 292 |
|
| 293 |
-
# CSS
|
| 294 |
st.markdown("""
|
| 295 |
<style>
|
| 296 |
.header-box {
|
|
@@ -311,37 +311,48 @@ st.markdown("""
|
|
| 311 |
display: flex;
|
| 312 |
align-items: center;
|
| 313 |
justify-content: flex-end;
|
| 314 |
-
width:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
height: auto;
|
| 316 |
}
|
| 317 |
</style>
|
| 318 |
""", unsafe_allow_html=True)
|
| 319 |
|
| 320 |
-
#
|
| 321 |
with st.container():
|
| 322 |
st.markdown('<div class="header-box">', unsafe_allow_html=True)
|
| 323 |
-
col1, col2, col3 = st.columns([1, 5, 1]) # tengah lebih besar
|
| 324 |
|
| 325 |
-
|
|
|
|
|
|
|
| 326 |
with col1:
|
| 327 |
st.write("")
|
| 328 |
|
| 329 |
-
# CENTER
|
| 330 |
with col2:
|
| 331 |
st.markdown("""
|
| 332 |
<div class="header-title">
|
| 333 |
<h1 style="margin-bottom:6px;">Proactive Safety Intelligence & Analytics Dashboard</h1>
|
| 334 |
-
<p style="color:#546e7a; font-size:1.05em; margin-top:-8px;">
|
| 335 |
-
</p>
|
| 336 |
</div>
|
| 337 |
""", unsafe_allow_html=True)
|
| 338 |
|
| 339 |
-
# RIGHT
|
| 340 |
with col3:
|
| 341 |
-
|
| 342 |
-
st.
|
| 343 |
-
|
| 344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
|
| 346 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 347 |
|
|
@@ -363,7 +374,6 @@ import streamlit as st
|
|
| 363 |
import plotly.graph_objects as go
|
| 364 |
import numpy as np
|
| 365 |
import pandas as pd
|
| 366 |
-
|
| 367 |
# =================== OBJECTIVE 1 - Company Reporting Activity (Polar Bar Chart) ===================
|
| 368 |
st.markdown(
|
| 369 |
"""
|
|
@@ -491,22 +501,18 @@ if 'temuan_kode_distrik' in df_local.columns:
|
|
| 491 |
current_angle += a
|
| 492 |
|
| 493 |
fig = go.Figure()
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
text=[comp],
|
| 507 |
-
name=comp, # 🔥 Nama perusahaan untuk legend
|
| 508 |
-
showlegend=True # 🔥 Tampilkan di legend
|
| 509 |
-
))
|
| 510 |
|
| 511 |
fig.update_layout(
|
| 512 |
title=f'{area_name} Area',
|
|
@@ -598,6 +604,8 @@ if 'temuan_kode_distrik' in df_local.columns:
|
|
| 598 |
else:
|
| 599 |
st.error("Column 'temuan_kode_distrik' not found in the data. Cannot determine PG/UM areas.")
|
| 600 |
st.stop()
|
|
|
|
|
|
|
| 601 |
# =================== OBJECTIVE 2 — Active vs Inactive Locations (Treemap with Color Gradient) ===================
|
| 602 |
st.markdown(
|
| 603 |
"""
|
|
|
|
| 290 |
import streamlit as st
|
| 291 |
import os
|
| 292 |
|
| 293 |
+
# CSS HEADER BOX
|
| 294 |
st.markdown("""
|
| 295 |
<style>
|
| 296 |
.header-box {
|
|
|
|
| 311 |
display: flex;
|
| 312 |
align-items: center;
|
| 313 |
justify-content: flex-end;
|
| 314 |
+
width: 220px; /* 🔥 Logo area bigger */
|
| 315 |
+
height: auto;
|
| 316 |
+
}
|
| 317 |
+
.logo-img {
|
| 318 |
+
max-width: 200px; /* 🔥 Logo bigger */
|
| 319 |
height: auto;
|
| 320 |
}
|
| 321 |
</style>
|
| 322 |
""", unsafe_allow_html=True)
|
| 323 |
|
| 324 |
+
# === HEADER LAYOUT ===
|
| 325 |
with st.container():
|
| 326 |
st.markdown('<div class="header-box">', unsafe_allow_html=True)
|
|
|
|
| 327 |
|
| 328 |
+
col1, col2, col3 = st.columns([1, 5, 1])
|
| 329 |
+
|
| 330 |
+
# Left (empty)
|
| 331 |
with col1:
|
| 332 |
st.write("")
|
| 333 |
|
| 334 |
+
# CENTER TITLE
|
| 335 |
with col2:
|
| 336 |
st.markdown("""
|
| 337 |
<div class="header-title">
|
| 338 |
<h1 style="margin-bottom:6px;">Proactive Safety Intelligence & Analytics Dashboard</h1>
|
| 339 |
+
<p style="color:#546e7a; font-size:1.05em; margin-top:-8px;"></p>
|
|
|
|
| 340 |
</div>
|
| 341 |
""", unsafe_allow_html=True)
|
| 342 |
|
| 343 |
+
# RIGHT LOGO (NOW BIGGER)
|
| 344 |
with col3:
|
| 345 |
+
if os.path.exists("pln.png"):
|
| 346 |
+
st.markdown(
|
| 347 |
+
f"""
|
| 348 |
+
<div class="logo-container">
|
| 349 |
+
<img src="pln.png" class="logo-img">
|
| 350 |
+
</div>
|
| 351 |
+
""",
|
| 352 |
+
unsafe_allow_html=True,
|
| 353 |
+
)
|
| 354 |
+
else:
|
| 355 |
+
st.write("")
|
| 356 |
|
| 357 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 358 |
|
|
|
|
| 374 |
import plotly.graph_objects as go
|
| 375 |
import numpy as np
|
| 376 |
import pandas as pd
|
|
|
|
| 377 |
# =================== OBJECTIVE 1 - Company Reporting Activity (Polar Bar Chart) ===================
|
| 378 |
st.markdown(
|
| 379 |
"""
|
|
|
|
| 501 |
current_angle += a
|
| 502 |
|
| 503 |
fig = go.Figure()
|
| 504 |
+
fig.add_trace(go.Barpolar(
|
| 505 |
+
r=ratios,
|
| 506 |
+
theta=mid_angles,
|
| 507 |
+
width=angles,
|
| 508 |
+
marker_color=colors,
|
| 509 |
+
marker_line_color="white",
|
| 510 |
+
marker_line_width=1.2,
|
| 511 |
+
opacity=0.9,
|
| 512 |
+
hovertemplate="<b>%{text}</b><br>Avg Ratio: %{r:.2f}<extra></extra>",
|
| 513 |
+
text=companies,
|
| 514 |
+
name='Companies', # Nama trace untuk legend
|
| 515 |
+
))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 516 |
|
| 517 |
fig.update_layout(
|
| 518 |
title=f'{area_name} Area',
|
|
|
|
| 604 |
else:
|
| 605 |
st.error("Column 'temuan_kode_distrik' not found in the data. Cannot determine PG/UM areas.")
|
| 606 |
st.stop()
|
| 607 |
+
|
| 608 |
+
|
| 609 |
# =================== OBJECTIVE 2 — Active vs Inactive Locations (Treemap with Color Gradient) ===================
|
| 610 |
st.markdown(
|
| 611 |
"""
|