Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -612,36 +612,43 @@ avg_ratio_per_location = merged_loc.groupby('nama_lokasi_full')['ratio'].mean().
|
|
| 612 |
# Filter hasil akhir untuk menghindari NaN
|
| 613 |
avg_ratio_per_location = avg_ratio_per_location.dropna(subset=['avg_monthly_ratio'])
|
| 614 |
|
| 615 |
-
|
| 616 |
-
|
|
|
|
|
|
|
| 617 |
fig_treemap = px.treemap(
|
| 618 |
avg_ratio_per_location,
|
| 619 |
path=['nama_lokasi_full'],
|
| 620 |
values='avg_monthly_ratio',
|
| 621 |
-
title='Monthly Finding by Location',
|
| 622 |
labels={
|
| 623 |
-
'avg_monthly_ratio': 'Monthly Finding/Person Ratio',
|
| 624 |
'nama_lokasi_full': 'Location'
|
| 625 |
},
|
| 626 |
color='avg_monthly_ratio',
|
| 627 |
color_continuous_scale=[
|
| 628 |
-
[0.0, '#D32F2F'],
|
| 629 |
-
[0.5, '#FFB300'],
|
| 630 |
-
[1.0, '#4CAF50']
|
| 631 |
]
|
| 632 |
)
|
| 633 |
|
| 634 |
-
#
|
| 635 |
fig_treemap.update_layout(
|
| 636 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 637 |
)
|
| 638 |
|
| 639 |
-
#
|
| 640 |
fig_treemap.update_traces(
|
| 641 |
textfont=dict(size=12)
|
| 642 |
)
|
| 643 |
|
| 644 |
-
st.plotly_chart(fig_treemap)
|
| 645 |
|
| 646 |
# Format hover
|
| 647 |
fig_treemap.update_traces(
|
|
|
|
| 612 |
# Filter hasil akhir untuk menghindari NaN
|
| 613 |
avg_ratio_per_location = avg_ratio_per_location.dropna(subset=['avg_monthly_ratio'])
|
| 614 |
|
| 615 |
+
if avg_ratio_per_location.empty:
|
| 616 |
+
st.write("Data kosong.")
|
| 617 |
+
else:
|
| 618 |
+
# Treemap dengan gradasi warna: merah → kuning → hijau
|
| 619 |
fig_treemap = px.treemap(
|
| 620 |
avg_ratio_per_location,
|
| 621 |
path=['nama_lokasi_full'],
|
| 622 |
values='avg_monthly_ratio',
|
| 623 |
+
title='Avg Monthly Finding by Location',
|
| 624 |
labels={
|
| 625 |
+
'avg_monthly_ratio': 'Avg Monthly Finding/Person Ratio',
|
| 626 |
'nama_lokasi_full': 'Location'
|
| 627 |
},
|
| 628 |
color='avg_monthly_ratio',
|
| 629 |
color_continuous_scale=[
|
| 630 |
+
[0.0, '#D32F2F'], # Merah - rendah
|
| 631 |
+
[0.5, '#FFB300'], # Kuning - sedang
|
| 632 |
+
[1.0, '#4CAF50'] # Hijau - tinggi
|
| 633 |
]
|
| 634 |
)
|
| 635 |
|
| 636 |
+
# Set ukuran font label menjadi 12
|
| 637 |
fig_treemap.update_layout(
|
| 638 |
+
title_font_size=14,
|
| 639 |
+
font=dict(size=12), # Semua font default = 12
|
| 640 |
+
coloraxis_colorbar=dict(
|
| 641 |
+
title_font=dict(size=12),
|
| 642 |
+
tickfont=dict(size=12)
|
| 643 |
+
)
|
| 644 |
)
|
| 645 |
|
| 646 |
+
# Label teks dalam treemap juga diset ke 12
|
| 647 |
fig_treemap.update_traces(
|
| 648 |
textfont=dict(size=12)
|
| 649 |
)
|
| 650 |
|
| 651 |
+
st.plotly_chart(fig_treemap, use_container_width=True)
|
| 652 |
|
| 653 |
# Format hover
|
| 654 |
fig_treemap.update_traces(
|