SHELLAPANDIANGANHUNGING commited on
Commit
9317ec6
·
verified ·
1 Parent(s): 818c9ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -1046,7 +1046,6 @@ with col_3d:
1046
  )
1047
  st.markdown(insight_text, unsafe_allow_html=True)
1048
 
1049
-
1050
  try:
1051
  from wordcloud import WordCloud
1052
  import matplotlib.pyplot as plt
@@ -1058,6 +1057,10 @@ except ImportError:
1058
  st.markdown("<h3 class='section-title'>OBJECTIVE 4 - What Unsafe Issues Appear Most Often?</h3>",
1059
  unsafe_allow_html=True)
1060
 
 
 
 
 
1061
  if WORDCLOUD_AVAILABLE:
1062
 
1063
  # 🔥 Pie Chart: Semua data (tidak difilter)
@@ -1072,6 +1075,9 @@ if WORDCLOUD_AVAILABLE:
1072
 
1073
  # === PIE CHART: Semua temuan_kategori (Warna Sesuai Kategori) ===
1074
  with col1:
 
 
 
1075
  if 'temuan_kategori' in df_all_kategori.columns:
1076
  # Hitung jumlah per kategori
1077
  category_counts = df_all_kategori['temuan_kategori'].value_counts()
@@ -1091,22 +1097,14 @@ if WORDCLOUD_AVAILABLE:
1091
  else:
1092
  colors.append('#9E9E9E') # Default abu-abu
1093
 
1094
- # Buat pie chart
1095
  fig_pie = px.pie(
1096
  names=category_counts.index,
1097
  values=category_counts.values,
1098
- title="Distribution of All Issue Categories",
1099
  color_discrete_sequence=colors
1100
  )
1101
  fig_pie.update_traces(textposition='inside', textinfo='percent+label')
1102
- fig_pie.update_layout(
1103
- height=500,
1104
- title=dict(
1105
- font=dict(size=16, family="Arial", color="#2c3e50", weight="bold"),
1106
- x=0.5,
1107
- xanchor="center"
1108
- )
1109
- )
1110
  st.plotly_chart(fig_pie, use_container_width=True)
1111
  else:
1112
  st.warning("No data available for pie chart.")
@@ -1115,6 +1113,9 @@ if WORDCLOUD_AVAILABLE:
1115
 
1116
  # === WORDCLOUD: Hanya Non-Positive (dari keyword_kategori) ===
1117
  with col2:
 
 
 
1118
  if df_filtered_kategori.empty:
1119
  st.warning("No data available after filtering out 'Positive' category.")
1120
  else:
@@ -1137,7 +1138,6 @@ if WORDCLOUD_AVAILABLE:
1137
 
1138
  # Output kecil tapi tajam
1139
  fig, ax = plt.subplots(figsize=(3, 2), dpi=200)
1140
- ax.set_title("Unsafe Issues", fontsize=16, fontname="Arial", color="#2c3e50", weight="bold")
1141
  ax.imshow(wordcloud, interpolation='bilinear')
1142
  ax.axis('off')
1143
  plt.tight_layout()
@@ -1150,6 +1150,7 @@ if WORDCLOUD_AVAILABLE:
1150
 
1151
  else:
1152
  st.info("WordCloud library not installed. Install `wordcloud` and `matplotlib` to enable this feature.")
 
1153
  # =================== 5. Matrix (Tetap Dipertahankan) ===================
1154
  st.markdown("<h3 class='section-title'>OBJECTIVE 5 - Findings vs Lead Time: Which Divisions Move Slow?</h3>", unsafe_allow_html=True)
1155
 
 
1046
  )
1047
  st.markdown(insight_text, unsafe_allow_html=True)
1048
 
 
1049
  try:
1050
  from wordcloud import WordCloud
1051
  import matplotlib.pyplot as plt
 
1057
  st.markdown("<h3 class='section-title'>OBJECTIVE 4 - What Unsafe Issues Appear Most Often?</h3>",
1058
  unsafe_allow_html=True)
1059
 
1060
+ # 🔹 Fungsi untuk membuat judul seragam
1061
+ def create_consistent_title(title_text):
1062
+ return f"<div style='font-family: Arial; font-size: 16px; font-weight: bold; color: #2c3e50; text-align: center; margin-bottom: 8px;'>{title_text}</div>"
1063
+
1064
  if WORDCLOUD_AVAILABLE:
1065
 
1066
  # 🔥 Pie Chart: Semua data (tidak difilter)
 
1075
 
1076
  # === PIE CHART: Semua temuan_kategori (Warna Sesuai Kategori) ===
1077
  with col1:
1078
+ # Tampilkan judul terpisah
1079
+ st.markdown(create_consistent_title("Distribution of All Issue Categories"), unsafe_allow_html=True)
1080
+
1081
  if 'temuan_kategori' in df_all_kategori.columns:
1082
  # Hitung jumlah per kategori
1083
  category_counts = df_all_kategori['temuan_kategori'].value_counts()
 
1097
  else:
1098
  colors.append('#9E9E9E') # Default abu-abu
1099
 
1100
+ # Buat pie chart tanpa judul
1101
  fig_pie = px.pie(
1102
  names=category_counts.index,
1103
  values=category_counts.values,
 
1104
  color_discrete_sequence=colors
1105
  )
1106
  fig_pie.update_traces(textposition='inside', textinfo='percent+label')
1107
+ fig_pie.update_layout(height=450)
 
 
 
 
 
 
 
1108
  st.plotly_chart(fig_pie, use_container_width=True)
1109
  else:
1110
  st.warning("No data available for pie chart.")
 
1113
 
1114
  # === WORDCLOUD: Hanya Non-Positive (dari keyword_kategori) ===
1115
  with col2:
1116
+ # Tampilkan judul terpisah
1117
+ st.markdown(create_consistent_title("Unsafe Issues"), unsafe_allow_html=True)
1118
+
1119
  if df_filtered_kategori.empty:
1120
  st.warning("No data available after filtering out 'Positive' category.")
1121
  else:
 
1138
 
1139
  # Output kecil tapi tajam
1140
  fig, ax = plt.subplots(figsize=(3, 2), dpi=200)
 
1141
  ax.imshow(wordcloud, interpolation='bilinear')
1142
  ax.axis('off')
1143
  plt.tight_layout()
 
1150
 
1151
  else:
1152
  st.info("WordCloud library not installed. Install `wordcloud` and `matplotlib` to enable this feature.")
1153
+
1154
  # =================== 5. Matrix (Tetap Dipertahankan) ===================
1155
  st.markdown("<h3 class='section-title'>OBJECTIVE 5 - Findings vs Lead Time: Which Divisions Move Slow?</h3>", unsafe_allow_html=True)
1156