SHELLAPANDIANGANHUNGING commited on
Commit
fd1f50e
·
verified ·
1 Parent(s): b2cb83a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -1088,21 +1088,25 @@ if WORDCLOUD_AVAILABLE:
1088
  colors.append('#2E7D32') # Hijau
1089
  else:
1090
  # Gradasi merah pastel: dari gelap ke terang
1091
- # Urutan: index 0 = terbanyak
1092
  idx = list(category_counts.index).index(cat)
1093
- # Misal: 0 → merah gelap, 1 → sedikit lebih terang, dst.
1094
- # Gunakan indeks untuk gradasi
1095
  total_non_positive = len([c for c in category_counts.index if c != 'Positive'])
1096
- if total_non_positive > 0:
1097
- # Buat gradasi dari merah gelap ke terang
1098
- step = idx / max(1, total_non_positive - 1) if total_non_positive > 1 else 0
1099
- # Rentang merah pastel: #c62828 ke #ffebee
1100
- r = int(198 - (198 - 255) * step)
1101
- g = int(40 - (40 - 235) * step)
1102
- b = int(40 - (40 - 238) * step)
1103
- color_hex = f"#{r:02x}{g:02x}{b:02x}"
1104
  else:
1105
- color_hex = "#c62828" # Default merah gelap
 
 
 
 
 
 
 
 
 
 
 
 
1106
  colors.append(color_hex)
1107
 
1108
  # Buat pie chart
@@ -1158,7 +1162,6 @@ if WORDCLOUD_AVAILABLE:
1158
  else:
1159
  st.info("WordCloud library not installed. Install `wordcloud` and `matplotlib` to enable this feature.")
1160
 
1161
-
1162
  # =================== 5. Matrix (Tetap Dipertahankan) ===================
1163
  st.markdown("<h3 class='section-title'>OBJECTIVE 5 - Findings vs Lead Time: Which Divisions Move Slow?</h3>", unsafe_allow_html=True)
1164
 
 
1088
  colors.append('#2E7D32') # Hijau
1089
  else:
1090
  # Gradasi merah pastel: dari gelap ke terang
 
1091
  idx = list(category_counts.index).index(cat)
 
 
1092
  total_non_positive = len([c for c in category_counts.index if c != 'Positive'])
1093
+
1094
+ if total_non_positive > 1:
1095
+ step = idx / (total_non_positive - 1)
 
 
 
 
 
1096
  else:
1097
+ step = 0
1098
+
1099
+ # Rentang merah pastel: dari #c62828 ke #ffebee
1100
+ r = int(198 + (255 - 198) * step)
1101
+ g = int(40 + (235 - 40) * step)
1102
+ b = int(40 + (238 - 40) * step)
1103
+
1104
+ # Pastikan nilai tidak melebihi 255
1105
+ r = min(255, max(0, r))
1106
+ g = min(255, max(0, g))
1107
+ b = min(255, max(0, b))
1108
+
1109
+ color_hex = f"#{r:02x}{g:02x}{b:02x}"
1110
  colors.append(color_hex)
1111
 
1112
  # Buat pie chart
 
1162
  else:
1163
  st.info("WordCloud library not installed. Install `wordcloud` and `matplotlib` to enable this feature.")
1164
 
 
1165
  # =================== 5. Matrix (Tetap Dipertahankan) ===================
1166
  st.markdown("<h3 class='section-title'>OBJECTIVE 5 - Findings vs Lead Time: Which Divisions Move Slow?</h3>", unsafe_allow_html=True)
1167