SHELLAPANDIANGANHUNGING commited on
Commit
87e04cd
·
verified ·
1 Parent(s): 9b80bc8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -33
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
- fig.add_trace(go.Barpolar(
506
- r=ratios,
507
- theta=mid_angles,
508
- width=angles,
509
- marker_color=colors,
510
- marker_line_color="white",
511
- marker_line_width=1.2,
512
- opacity=0.9,
513
- hovertemplate="<b>%{text}</b><br>Avg Ratio: %{r:.2f}<extra></extra>",
514
- text=companies,
515
- name='Companies', # Nama trace untuk legend
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
- showlegend=True, # 🔥 Aktifkan legend
537
- legend=dict(
538
- orientation="v",
539
- yanchor="top", # 🔥 Atas
540
- y=1,
541
- xanchor="right", # 🔥 Kanan
542
- x=1.02,
543
- font=dict(size=10)
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)