SHELLAPANDIANGANHUNGING commited on
Commit
b684e8a
Β·
verified Β·
1 Parent(s): 065f0df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -15
app.py CHANGED
@@ -751,17 +751,17 @@ def create_radial_chart(pos_data, title, shift_hours, shift_type):
751
  # Total per jam
752
  total_per_hour = hourly_normal + hourly_amber + hourly_red
753
 
754
- # Sudut: sesuai shift
755
  if shift_type == 'pagi':
756
- # Shift Pagi (06:00–18:00) β†’ 0Β° = 06:00, 90Β° = 09:00, 180Β° = 12:00, 270Β° = 15:00
757
- theta = [(h - 6) * 30 for h in shift_hours] # 12 jam * 30Β° = 360Β°
758
  tickvals = [0, 90, 180, 270]
759
- ticktext = ["06:00", "09:00", "12:00", "15:00"]
760
  else: # Shift Sore (18:00–06:00)
761
- # Shift Sore (18:00–06:00) β†’ 0Β° = 18:00, 90Β° = 21:00, 180Β° = 00:00, 270Β° = 03:00
762
- theta = [(h - 18) * 30 if h >= 18 else (h + 6) * 30 for h in shift_hours] # 12 jam * 30Β° = 360Β°
763
  tickvals = [0, 90, 180, 270]
764
- ticktext = ["18:00", "21:00", "00:00", "03:00"]
765
 
766
  fig = go.Figure()
767
  fig.add_trace(go.Barpolar(
@@ -811,7 +811,7 @@ def create_radial_chart(pos_data, title, shift_hours, shift_type):
811
  # =============== ROW 1: Position 1 & 2 (Pagi & Sore) ===============
812
  with col1:
813
  # Position 1 Pagi (06:00–18:00)
814
- st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 1 (06:00–18:00)</h6>', unsafe_allow_html=True)
815
  pos1_data = alarm_data[alarm_data['Position'] == 1].copy()
816
  pos1_data = pos1_data[pos1_data['hour'].between(6, 17, inclusive='both')]
817
  fig1 = create_radial_chart(pos1_data, "Position 1 (06:00–18:00)", list(range(6, 18)), 'pagi')
@@ -822,7 +822,7 @@ with col1:
822
 
823
  with col2:
824
  # Position 1 Sore (18:00–06:00)
825
- st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 1 (18:00–06:00)</h6>', unsafe_allow_html=True)
826
  pos1_data = alarm_data[alarm_data['Position'] == 1].copy()
827
  pos1_data = pos1_data[~pos1_data['hour'].between(6, 17, inclusive='both')]
828
  fig2 = create_radial_chart(pos1_data, "Position 1 (18:00–06:00)", list(range(18, 24)) + list(range(0, 6)), 'sore')
@@ -833,7 +833,7 @@ with col2:
833
 
834
  with col3:
835
  # Position 2 Pagi (06:00–18:00)
836
- st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 2 (06:00–18:00)</h6>', unsafe_allow_html=True)
837
  pos2_data = alarm_data[alarm_data['Position'] == 2].copy()
838
  pos2_data = pos2_data[pos2_data['hour'].between(6, 17, inclusive='both')]
839
  fig3 = create_radial_chart(pos2_data, "Position 2 (06:00–18:00)", list(range(6, 18)), 'pagi')
@@ -844,7 +844,7 @@ with col3:
844
 
845
  with col4:
846
  # Position 2 Sore (18:00–06:00)
847
- st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 2 (18:00–06:00)</h6>', unsafe_allow_html=True)
848
  pos2_data = alarm_data[alarm_data['Position'] == 2].copy()
849
  pos2_data = pos2_data[~pos2_data['hour'].between(6, 17, inclusive='both')]
850
  fig4 = create_radial_chart(pos2_data, "Position 2 (18:00–06:00)", list(range(18, 24)) + list(range(0, 6)), 'sore')
@@ -856,7 +856,7 @@ with col4:
856
  # =============== ROW 2: Position 3 & 4 (Pagi & Sore) ===============
857
  with col5:
858
  # Position 3 Pagi (06:00–18:00)
859
- st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 3 (06:00–18:00)</h6>', unsafe_allow_html=True)
860
  pos3_data = alarm_data[alarm_data['Position'] == 3].copy()
861
  pos3_data = pos3_data[pos3_data['hour'].between(6, 17, inclusive='both')]
862
  fig5 = create_radial_chart(pos3_data, "Position 3 (06:00–18:00)", list(range(6, 18)), 'pagi')
@@ -867,7 +867,7 @@ with col5:
867
 
868
  with col6:
869
  # Position 3 Sore (18:00–06:00)
870
- st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 3 (18:00–06:00)</h6>', unsafe_allow_html=True)
871
  pos3_data = alarm_data[alarm_data['Position'] == 3].copy()
872
  pos3_data = pos3_data[~pos3_data['hour'].between(6, 17, inclusive='both')]
873
  fig6 = create_radial_chart(pos3_data, "Position 3 (18:00–06:00)", list(range(18, 24)) + list(range(0, 6)), 'sore')
@@ -878,7 +878,7 @@ with col6:
878
 
879
  with col7:
880
  # Position 4 Pagi (06:00–18:00)
881
- st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 4 (06:00–18:00)</h6>', unsafe_allow_html=True)
882
  pos4_data = alarm_data[alarm_data['Position'] == 4].copy()
883
  pos4_data = pos4_data[pos4_data['hour'].between(6, 17, inclusive='both')]
884
  fig7 = create_radial_chart(pos4_data, "Position 4 (06:00–18:00)", list(range(6, 18)), 'pagi')
@@ -889,7 +889,7 @@ with col7:
889
 
890
  with col8:
891
  # Position 4 Sore (18:00–06:00)
892
- st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 4 (18:00–06:00)</h6>', unsafe_allow_html=True)
893
  pos4_data = alarm_data[alarm_data['Position'] == 4].copy()
894
  pos4_data = pos4_data[~pos4_data['hour'].between(6, 17, inclusive='both')]
895
  fig8 = create_radial_chart(pos4_data, "Position 4 (18:00–06:00)", list(range(18, 24)) + list(range(0, 6)), 'sore')
@@ -942,6 +942,7 @@ st.markdown(f"""
942
  </div>
943
  </div>
944
  """, unsafe_allow_html=True)
 
945
  # ================= OBJECTIVE 3 =================
946
  st.markdown('<h3 class="objective-title">OBJECTIVE 4: Correlation β€” How Does Heat Influence Pressure and Which Tyres Trigger Red Alarms?</h3>', unsafe_allow_html=True)
947
 
 
751
  # Total per jam
752
  total_per_hour = hourly_normal + hourly_amber + hourly_red
753
 
754
+ # Sudut: selalu 0Β° = 12, 90Β° = 3, 180Β° = 6, 270Β° = 9
755
  if shift_type == 'pagi':
756
+ # Shift Pagi (06:00–18:00) β†’ 0Β° = 12, 90Β° = 3, 180Β° = 6, 270Β° = 9
757
+ theta = [(h - 12) * 30 for h in shift_hours] # 12 jam * 30Β° = 360Β°
758
  tickvals = [0, 90, 180, 270]
759
+ ticktext = ["12:00", "03:00", "06:00", "09:00"]
760
  else: # Shift Sore (18:00–06:00)
761
+ # Shift Sore (18:00–06:00) β†’ 0Β° = 12, 90Β° = 3, 180Β° = 6, 270Β° = 9
762
+ theta = [(h - 12) * 30 if h >= 12 else (h + 12) * 30 for h in shift_hours] # 12 jam * 30Β° = 360Β°
763
  tickvals = [0, 90, 180, 270]
764
+ ticktext = ["12:00", "03:00", "06:00", "09:00"]
765
 
766
  fig = go.Figure()
767
  fig.add_trace(go.Barpolar(
 
811
  # =============== ROW 1: Position 1 & 2 (Pagi & Sore) ===============
812
  with col1:
813
  # Position 1 Pagi (06:00–18:00)
814
+ st.markdown('<h6 style="text-align:center; margin-top: 0; margin-bottom: 8px;">Position 1 (06:00–18:00)</h6>', unsafe_allow_html=True)
815
  pos1_data = alarm_data[alarm_data['Position'] == 1].copy()
816
  pos1_data = pos1_data[pos1_data['hour'].between(6, 17, inclusive='both')]
817
  fig1 = create_radial_chart(pos1_data, "Position 1 (06:00–18:00)", list(range(6, 18)), 'pagi')
 
822
 
823
  with col2:
824
  # Position 1 Sore (18:00–06:00)
825
+ st.markdown('<h6 style="text-align:center; margin-top: 0; margin-bottom: 8px;">Position 1 (18:00–06:00)</h6>', unsafe_allow_html=True)
826
  pos1_data = alarm_data[alarm_data['Position'] == 1].copy()
827
  pos1_data = pos1_data[~pos1_data['hour'].between(6, 17, inclusive='both')]
828
  fig2 = create_radial_chart(pos1_data, "Position 1 (18:00–06:00)", list(range(18, 24)) + list(range(0, 6)), 'sore')
 
833
 
834
  with col3:
835
  # Position 2 Pagi (06:00–18:00)
836
+ st.markdown('<h6 style="text-align:center; margin-top: 0; margin-bottom: 8px;">Position 2 (06:00–18:00)</h6>', unsafe_allow_html=True)
837
  pos2_data = alarm_data[alarm_data['Position'] == 2].copy()
838
  pos2_data = pos2_data[pos2_data['hour'].between(6, 17, inclusive='both')]
839
  fig3 = create_radial_chart(pos2_data, "Position 2 (06:00–18:00)", list(range(6, 18)), 'pagi')
 
844
 
845
  with col4:
846
  # Position 2 Sore (18:00–06:00)
847
+ st.markdown('<h6 style="text-align:center; margin-top: 0; margin-bottom: 8px;">Position 2 (18:00–06:00)</h6>', unsafe_allow_html=True)
848
  pos2_data = alarm_data[alarm_data['Position'] == 2].copy()
849
  pos2_data = pos2_data[~pos2_data['hour'].between(6, 17, inclusive='both')]
850
  fig4 = create_radial_chart(pos2_data, "Position 2 (18:00–06:00)", list(range(18, 24)) + list(range(0, 6)), 'sore')
 
856
  # =============== ROW 2: Position 3 & 4 (Pagi & Sore) ===============
857
  with col5:
858
  # Position 3 Pagi (06:00–18:00)
859
+ st.markdown('<h6 style="text-align:center; margin-top: 0; margin-bottom: 8px;">Position 3 (06:00–18:00)</h6>', unsafe_allow_html=True)
860
  pos3_data = alarm_data[alarm_data['Position'] == 3].copy()
861
  pos3_data = pos3_data[pos3_data['hour'].between(6, 17, inclusive='both')]
862
  fig5 = create_radial_chart(pos3_data, "Position 3 (06:00–18:00)", list(range(6, 18)), 'pagi')
 
867
 
868
  with col6:
869
  # Position 3 Sore (18:00–06:00)
870
+ st.markdown('<h6 style="text-align:center; margin-top: 0; margin-bottom: 8px;">Position 3 (18:00–06:00)</h6>', unsafe_allow_html=True)
871
  pos3_data = alarm_data[alarm_data['Position'] == 3].copy()
872
  pos3_data = pos3_data[~pos3_data['hour'].between(6, 17, inclusive='both')]
873
  fig6 = create_radial_chart(pos3_data, "Position 3 (18:00–06:00)", list(range(18, 24)) + list(range(0, 6)), 'sore')
 
878
 
879
  with col7:
880
  # Position 4 Pagi (06:00–18:00)
881
+ st.markdown('<h6 style="text-align:center; margin-top: 0; margin-bottom: 8px;">Position 4 (06:00–18:00)</h6>', unsafe_allow_html=True)
882
  pos4_data = alarm_data[alarm_data['Position'] == 4].copy()
883
  pos4_data = pos4_data[pos4_data['hour'].between(6, 17, inclusive='both')]
884
  fig7 = create_radial_chart(pos4_data, "Position 4 (06:00–18:00)", list(range(6, 18)), 'pagi')
 
889
 
890
  with col8:
891
  # Position 4 Sore (18:00–06:00)
892
+ st.markdown('<h6 style="text-align:center; margin-top: 0; margin-bottom: 8px;">Position 4 (18:00–06:00)</h6>', unsafe_allow_html=True)
893
  pos4_data = alarm_data[alarm_data['Position'] == 4].copy()
894
  pos4_data = pos4_data[~pos4_data['hour'].between(6, 17, inclusive='both')]
895
  fig8 = create_radial_chart(pos4_data, "Position 4 (18:00–06:00)", list(range(18, 24)) + list(range(0, 6)), 'sore')
 
942
  </div>
943
  </div>
944
  """, unsafe_allow_html=True)
945
+
946
  # ================= OBJECTIVE 3 =================
947
  st.markdown('<h3 class="objective-title">OBJECTIVE 4: Correlation β€” How Does Heat Influence Pressure and Which Tyres Trigger Red Alarms?</h3>', unsafe_allow_html=True)
948