Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -359,22 +359,11 @@ with st.container():
|
|
| 359 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 360 |
|
| 361 |
|
| 362 |
-
|
| 363 |
import streamlit as st
|
| 364 |
import plotly.graph_objects as go
|
| 365 |
import numpy as np
|
| 366 |
import pandas as pd
|
| 367 |
|
| 368 |
-
import streamlit as st
|
| 369 |
-
import plotly.graph_objects as go
|
| 370 |
-
import numpy as np
|
| 371 |
-
import pandas as pd
|
| 372 |
-
|
| 373 |
-
# =================== OBJECTIVE 1 - Company Reporting Activity (Polar Bar Chart) ===================
|
| 374 |
-
import streamlit as st
|
| 375 |
-
import plotly.graph_objects as go
|
| 376 |
-
import numpy as np
|
| 377 |
-
import pandas as pd
|
| 378 |
# =================== OBJECTIVE 1 - Company Reporting Activity (Polar Bar Chart) ===================
|
| 379 |
st.markdown(
|
| 380 |
"""
|
|
@@ -502,18 +491,22 @@ if 'temuan_kode_distrik' in df_local.columns:
|
|
| 502 |
current_angle += a
|
| 503 |
|
| 504 |
fig = go.Figure()
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 517 |
|
| 518 |
fig.update_layout(
|
| 519 |
title=f'{area_name} Area',
|
|
@@ -533,20 +526,23 @@ if 'temuan_kode_distrik' in df_local.columns:
|
|
| 533 |
linecolor="white", # 🔥 Warna garis derajat jadi putih
|
| 534 |
gridcolor="rgba(255,255,255,0.2)" # 🔥 Warna grid derajat jadi transparan putih
|
| 535 |
),
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
)
|
|
|
|
| 545 |
margin=dict(t=40, b=20, l=20, r=20),
|
| 546 |
height=400,
|
| 547 |
paper_bgcolor="rgba(0,0,0,0)",
|
| 548 |
-
plot_bgcolor="rgba(0,0,0,0)"
|
|
|
|
| 549 |
|
|
|
|
| 550 |
|
| 551 |
# Plot
|
| 552 |
col1, col2 = st.columns(2)
|
|
|
|
| 359 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 360 |
|
| 361 |
|
|
|
|
| 362 |
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 |
current_angle += a
|
| 492 |
|
| 493 |
fig = go.Figure()
|
| 494 |
+
|
| 495 |
+
# 🔥 Tambahkan satu trace untuk setiap perusahaan agar muncul di legend
|
| 496 |
+
for i, (comp, ratio, color, angle) in enumerate(zip(companies, ratios, colors, angles)):
|
| 497 |
+
fig.add_trace(go.Barpolar(
|
| 498 |
+
r=[ratio],
|
| 499 |
+
theta=[mid_angles[i]],
|
| 500 |
+
width=[angle],
|
| 501 |
+
marker_color=[color],
|
| 502 |
+
marker_line_color="white",
|
| 503 |
+
marker_line_width=1.2,
|
| 504 |
+
opacity=0.9,
|
| 505 |
+
hovertemplate="<b>%{text}</b><br>Avg Ratio: %{r[0]:.2f}<extra></extra>",
|
| 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',
|
|
|
|
| 526 |
linecolor="white", # 🔥 Warna garis derajat jadi putih
|
| 527 |
gridcolor="rgba(255,255,255,0.2)" # 🔥 Warna grid derajat jadi transparan putih
|
| 528 |
),
|
| 529 |
+
),
|
| 530 |
+
showlegend=True, # 🔥 Aktifkan legend
|
| 531 |
+
legend=dict(
|
| 532 |
+
orientation="v",
|
| 533 |
+
yanchor="top", # 🔥 Atas
|
| 534 |
+
y=1,
|
| 535 |
+
xanchor="right", # 🔥 Kanan
|
| 536 |
+
x=1.02,
|
| 537 |
+
font=dict(size=10)
|
| 538 |
+
),
|
| 539 |
margin=dict(t=40, b=20, l=20, r=20),
|
| 540 |
height=400,
|
| 541 |
paper_bgcolor="rgba(0,0,0,0)",
|
| 542 |
+
plot_bgcolor="rgba(0,0,0,0)"
|
| 543 |
+
)
|
| 544 |
|
| 545 |
+
return fig
|
| 546 |
|
| 547 |
# Plot
|
| 548 |
col1, col2 = st.columns(2)
|