SHELLAPANDIANGANHUNGING commited on
Commit
a64a117
·
verified ·
1 Parent(s): a23258e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -941,7 +941,7 @@ with col_3b:
941
 
942
  if sort_option_3b == "Top 10":
943
  # Top 10 tercepat (terendah)
944
- subset_data = sorted_all_3b.tail(10)
945
  else:
946
  # Bottom 10 = terlama (tertinggi)
947
  subset_data = sorted_all_3b.tail(10).sort_values('avg_monthly_leadtime', ascending=False) # descending dalam subset
@@ -1009,7 +1009,7 @@ with col_3d:
1009
  sorted_all_3d = avg_leadtime_per_executor.sort_values('avg_monthly_leadtime', ascending=True).reset_index(drop=True)
1010
 
1011
  if sort_option_3d == "Top 10":
1012
- subset_data = sorted_all_3d.tail(10)
1013
  else:
1014
  subset_data = sorted_all_3d.tail(10).sort_values('avg_monthly_leadtime', ascending=False)
1015
 
@@ -1091,7 +1091,7 @@ if WORDCLOUD_AVAILABLE:
1091
  # 2 Kolom
1092
  col1, col2 = st.columns(2)
1093
 
1094
- # === PIE CHART: Semua temuan_kategori (Tanpa Legend Default, Custom Legend Khusus) ===
1095
  with col1:
1096
  st.markdown(create_consistent_title("Distribution of All Issue Categories"), unsafe_allow_html=True)
1097
 
@@ -1114,9 +1114,22 @@ if WORDCLOUD_AVAILABLE:
1114
  values=category_counts.values,
1115
  color_discrete_sequence=colors
1116
  )
 
 
 
 
 
 
 
 
 
 
 
 
1117
  fig_pie.update_traces(
1118
  textposition='inside',
1119
- textinfo='percent+label',
 
1120
  marker=dict(line=dict(color='#FFFFFF', width=1))
1121
  )
1122
  fig_pie.update_layout(
@@ -1132,7 +1145,6 @@ if WORDCLOUD_AVAILABLE:
1132
 
1133
  for cat in category_counts.index:
1134
  color = color_map.get(cat, '#9E9E9E')
1135
- # Gunakan garis horizontal kecil untuk SEMUA kategori (sesuai referensi)
1136
  item = (
1137
  f"<span style='display: inline-block; width: 16px; height: 4px; background-color: {color}; "
1138
  f"margin: 0 8px; border-radius: 1px;'></span>"
@@ -1140,7 +1152,6 @@ if WORDCLOUD_AVAILABLE:
1140
  )
1141
  legend_items.append(item)
1142
 
1143
- # Gabungkan semua item dengan pipa (|) sebagai pemisah
1144
  legend_html = " | ".join(legend_items)
1145
  st.markdown(f"<div>{legend_html}</div>", unsafe_allow_html=True)
1146
  st.markdown("</div>", unsafe_allow_html=True)
 
941
 
942
  if sort_option_3b == "Top 10":
943
  # Top 10 tercepat (terendah)
944
+ subset_data = sorted_all_3b.head(10).sort_values('avg_monthly_leadtime', ascending=True)
945
  else:
946
  # Bottom 10 = terlama (tertinggi)
947
  subset_data = sorted_all_3b.tail(10).sort_values('avg_monthly_leadtime', ascending=False) # descending dalam subset
 
1009
  sorted_all_3d = avg_leadtime_per_executor.sort_values('avg_monthly_leadtime', ascending=True).reset_index(drop=True)
1010
 
1011
  if sort_option_3d == "Top 10":
1012
+ subset_data = sorted_all_3d.tail(10).sort_values('avg_monthly_leadtime', ascending=True)
1013
  else:
1014
  subset_data = sorted_all_3d.tail(10).sort_values('avg_monthly_leadtime', ascending=False)
1015
 
 
1091
  # 2 Kolom
1092
  col1, col2 = st.columns(2)
1093
 
1094
+ # === PIE CHART: Semua temuan_kategori (Dengan Custom Text untuk Unsafe Action & Near Miss) ===
1095
  with col1:
1096
  st.markdown(create_consistent_title("Distribution of All Issue Categories"), unsafe_allow_html=True)
1097
 
 
1114
  values=category_counts.values,
1115
  color_discrete_sequence=colors
1116
  )
1117
+
1118
+ # ⚙️ Custom text template: untuk Unsafe Action & Near Miss, ganti label jadi "— value"
1119
+ labels = []
1120
+ for cat in category_counts.index:
1121
+ val = category_counts[cat]
1122
+ if cat in ['Unsafe Action', 'Near Miss']:
1123
+ # Gunakan simbol garis + angka
1124
+ labels.append(f"— {val}")
1125
+ else:
1126
+ # Tetap pakai nama kategori
1127
+ labels.append(cat)
1128
+
1129
  fig_pie.update_traces(
1130
  textposition='inside',
1131
+ textinfo='percent+text', # Gunakan text yang sudah dikustom
1132
+ text=labels, # Teks custom
1133
  marker=dict(line=dict(color='#FFFFFF', width=1))
1134
  )
1135
  fig_pie.update_layout(
 
1145
 
1146
  for cat in category_counts.index:
1147
  color = color_map.get(cat, '#9E9E9E')
 
1148
  item = (
1149
  f"<span style='display: inline-block; width: 16px; height: 4px; background-color: {color}; "
1150
  f"margin: 0 8px; border-radius: 1px;'></span>"
 
1152
  )
1153
  legend_items.append(item)
1154
 
 
1155
  legend_html = " | ".join(legend_items)
1156
  st.markdown(f"<div>{legend_html}</div>", unsafe_allow_html=True)
1157
  st.markdown("</div>", unsafe_allow_html=True)