SHELLAPANDIANGANHUNGING commited on
Commit
6f6e150
Β·
verified Β·
1 Parent(s): f1b9ca7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -524,16 +524,16 @@ def create_radial_chart(pos_data, title, shift_hours, shift_type):
524
  # Shift Pagi (06:00–18:00) β†’ 0Β° = 03:00, 90Β° = 06:00, 180Β° = 12:00, 270Β° = 18:00
525
  theta = [(h - 3) * 30 for h in shift_hours] # 12 jam * 30Β° = 360Β°
526
  tickvals = [0, 90, 180, 270]
527
- ticktext = ["03:00", "06:00", "12:00", "18:00"]
528
  else: # Shift Sore (18:00–06:00) β€” TAPI ikuti aturan jam seperti pagi
529
  # Shift Sore (18:00–06:00) β†’ 0Β° = 21:00, 90Β° = 00:00, 180Β° = 06:00, 270Β° = 12:00
530
  # Tapi karena ingin ikut aturan pagi, kita mapping jam agar 0Β° = 03:00, 90Β° = 06:00, 180Β° = 12:00, 270Β° = 18:00
531
  # Maka kita gunakan jam pagi (06:00–18:00) sebagai referensi jam, tapi data diambil dari sore (18:00–06:00)
532
  # Kita mapping: 18->06, 19->07, ..., 23->11, 00->12, 01->13, ..., 05->17
533
  # Maka: theta = [(mapped_h - 3) * 30] where mapped_h = h + 12 if h < 6 else h - 12
534
- theta = [(h + 12 if h < 6 else h - 12 - 3) * 30 for h in shift_hours] # 12 jam * 30Β° = 360Β°
535
  tickvals = [0, 90, 180, 270]
536
- ticktext = ["21:00", "00:00", "06:00", "12:00"]
537
 
538
  fig = go.Figure()
539
 
@@ -595,7 +595,7 @@ with col1:
595
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 1 (06:00–18:00)</div>', unsafe_allow_html=True)
596
  pos1_data = alarm_data[alarm_data['Position'] == 1].copy()
597
  pos1_data = pos1_data[pos1_data['hour'].between(6, 17, inclusive='both')]
598
- fig1 = create_radial_chart(pos1_data, "Position 1 (06:00–18:00)", list(range(6, 18)), 'pagi')
599
  if fig1 is not None:
600
  st.plotly_chart(fig1, use_container_width=True)
601
  else:
@@ -606,7 +606,7 @@ with col2:
606
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 1 (18:00–06:00)</div>', unsafe_allow_html=True)
607
  pos1_data = alarm_data[alarm_data['Position'] == 1].copy()
608
  pos1_data = pos1_data[~pos1_data['hour'].between(6, 17, inclusive='both')]
609
- fig2 = create_radial_chart(pos1_data, "Position 1 (18:00–06:00)", list(range(18, 24)) + list(range(0, 6)), 'sore')
610
  if fig2 is not None:
611
  st.plotly_chart(fig2, use_container_width=True)
612
  else:
@@ -617,7 +617,7 @@ with col3:
617
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 2 (06:00–18:00)</div>', unsafe_allow_html=True)
618
  pos2_data = alarm_data[alarm_data['Position'] == 2].copy()
619
  pos2_data = pos2_data[pos2_data['hour'].between(6, 17, inclusive='both')]
620
- fig3 = create_radial_chart(pos2_data, "Position 2 (06:00–18:00)", list(range(6, 18)), 'pagi')
621
  if fig3 is not None:
622
  st.plotly_chart(fig3, use_container_width=True)
623
  else:
@@ -628,7 +628,7 @@ with col4:
628
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 2 (18:00–06:00)</div>', unsafe_allow_html=True)
629
  pos2_data = alarm_data[alarm_data['Position'] == 2].copy()
630
  pos2_data = pos2_data[~pos2_data['hour'].between(6, 17, inclusive='both')]
631
- fig4 = create_radial_chart(pos2_data, "Position 2 (18:00–06:00)", list(range(18, 24)) + list(range(0, 6)), 'sore')
632
  if fig4 is not None:
633
  st.plotly_chart(fig4, use_container_width=True)
634
  else:
@@ -640,7 +640,7 @@ with col5:
640
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 3 (06:00–18:00)</div>', unsafe_allow_html=True)
641
  pos3_data = alarm_data[alarm_data['Position'] == 3].copy()
642
  pos3_data = pos3_data[pos3_data['hour'].between(6, 17, inclusive='both')]
643
- fig5 = create_radial_chart(pos3_data, "Position 3 (06:00–18:00)", list(range(6, 18)), 'pagi')
644
  if fig5 is not None:
645
  st.plotly_chart(fig5, use_container_width=True)
646
  else:
@@ -651,7 +651,7 @@ with col6:
651
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 3 (18:00–06:00)</div>', unsafe_allow_html=True)
652
  pos3_data = alarm_data[alarm_data['Position'] == 3].copy()
653
  pos3_data = pos3_data[~pos3_data['hour'].between(6, 17, inclusive='both')]
654
- fig6 = create_radial_chart(pos3_data, "Position 3 (18:00–06:00)", list(range(18, 24)) + list(range(0, 6)), 'sore')
655
  if fig6 is not None:
656
  st.plotly_chart(fig6, use_container_width=True)
657
  else:
@@ -662,7 +662,7 @@ with col7:
662
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 4 (06:00–18:00)</div>', unsafe_allow_html=True)
663
  pos4_data = alarm_data[alarm_data['Position'] == 4].copy()
664
  pos4_data = pos4_data[pos4_data['hour'].between(6, 17, inclusive='both')]
665
- fig7 = create_radial_chart(pos4_data, "Position 4 (06:00–18:00)", list(range(6, 18)), 'pagi')
666
  if fig7 is not None:
667
  st.plotly_chart(fig7, use_container_width=True)
668
  else:
@@ -673,7 +673,7 @@ with col8:
673
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 4 (18:00–06:00)</div>', unsafe_allow_html=True)
674
  pos4_data = alarm_data[alarm_data['Position'] == 4].copy()
675
  pos4_data = pos4_data[~pos4_data['hour'].between(6, 17, inclusive='both')]
676
- fig8 = create_radial_chart(pos4_data, "Position 4 (18:00–06:00)", list(range(18, 24)) + list(range(0, 6)), 'sore')
677
  if fig8 is not None:
678
  st.plotly_chart(fig8, use_container_width=True)
679
  else:
 
524
  # Shift Pagi (06:00–18:00) β†’ 0Β° = 03:00, 90Β° = 06:00, 180Β° = 12:00, 270Β° = 18:00
525
  theta = [(h - 3) * 30 for h in shift_hours] # 12 jam * 30Β° = 360Β°
526
  tickvals = [0, 90, 180, 270]
527
+ ticktext = ["15:00", "06:00/18:00", "09:00", "12:00"]
528
  else: # Shift Sore (18:00–06:00) β€” TAPI ikuti aturan jam seperti pagi
529
  # Shift Sore (18:00–06:00) β†’ 0Β° = 21:00, 90Β° = 00:00, 180Β° = 06:00, 270Β° = 12:00
530
  # Tapi karena ingin ikut aturan pagi, kita mapping jam agar 0Β° = 03:00, 90Β° = 06:00, 180Β° = 12:00, 270Β° = 18:00
531
  # Maka kita gunakan jam pagi (06:00–18:00) sebagai referensi jam, tapi data diambil dari sore (18:00–06:00)
532
  # Kita mapping: 18->06, 19->07, ..., 23->11, 00->12, 01->13, ..., 05->17
533
  # Maka: theta = [(mapped_h - 3) * 30] where mapped_h = h + 12 if h < 6 else h - 12
534
+ theta = [((h - 18) % 12) * 30 for h in shift_hours] # 12 jam * 30Β° = 360Β°
535
  tickvals = [0, 90, 180, 270]
536
+ ticktext = ["03:00", "18:00/06:00", "21:00", "00:00"]
537
 
538
  fig = go.Figure()
539
 
 
595
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 1 (06:00–18:00)</div>', unsafe_allow_html=True)
596
  pos1_data = alarm_data[alarm_data['Position'] == 1].copy()
597
  pos1_data = pos1_data[pos1_data['hour'].between(6, 17, inclusive='both')]
598
+ fig1 = create_radial_chart(pos1_data, "", list(range(6, 18)), 'pagi')
599
  if fig1 is not None:
600
  st.plotly_chart(fig1, use_container_width=True)
601
  else:
 
606
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 1 (18:00–06:00)</div>', unsafe_allow_html=True)
607
  pos1_data = alarm_data[alarm_data['Position'] == 1].copy()
608
  pos1_data = pos1_data[~pos1_data['hour'].between(6, 17, inclusive='both')]
609
+ fig2 = create_radial_chart(pos1_data, "", list(range(18, 24)) + list(range(0, 6)), 'sore')
610
  if fig2 is not None:
611
  st.plotly_chart(fig2, use_container_width=True)
612
  else:
 
617
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 2 (06:00–18:00)</div>', unsafe_allow_html=True)
618
  pos2_data = alarm_data[alarm_data['Position'] == 2].copy()
619
  pos2_data = pos2_data[pos2_data['hour'].between(6, 17, inclusive='both')]
620
+ fig3 = create_radial_chart(pos2_data, "", list(range(6, 18)), 'pagi')
621
  if fig3 is not None:
622
  st.plotly_chart(fig3, use_container_width=True)
623
  else:
 
628
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 2 (18:00–06:00)</div>', unsafe_allow_html=True)
629
  pos2_data = alarm_data[alarm_data['Position'] == 2].copy()
630
  pos2_data = pos2_data[~pos2_data['hour'].between(6, 17, inclusive='both')]
631
+ fig4 = create_radial_chart(pos2_data, "", list(range(18, 24)) + list(range(0, 6)), 'sore')
632
  if fig4 is not None:
633
  st.plotly_chart(fig4, use_container_width=True)
634
  else:
 
640
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 3 (06:00–18:00)</div>', unsafe_allow_html=True)
641
  pos3_data = alarm_data[alarm_data['Position'] == 3].copy()
642
  pos3_data = pos3_data[pos3_data['hour'].between(6, 17, inclusive='both')]
643
+ fig5 = create_radial_chart(pos3_data, "", list(range(6, 18)), 'pagi')
644
  if fig5 is not None:
645
  st.plotly_chart(fig5, use_container_width=True)
646
  else:
 
651
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 3 (18:00–06:00)</div>', unsafe_allow_html=True)
652
  pos3_data = alarm_data[alarm_data['Position'] == 3].copy()
653
  pos3_data = pos3_data[~pos3_data['hour'].between(6, 17, inclusive='both')]
654
+ fig6 = create_radial_chart(pos3_data, "", list(range(18, 24)) + list(range(0, 6)), 'sore')
655
  if fig6 is not None:
656
  st.plotly_chart(fig6, use_container_width=True)
657
  else:
 
662
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 4 (06:00–18:00)</div>', unsafe_allow_html=True)
663
  pos4_data = alarm_data[alarm_data['Position'] == 4].copy()
664
  pos4_data = pos4_data[pos4_data['hour'].between(6, 17, inclusive='both')]
665
+ fig7 = create_radial_chart(pos4_data, "", list(range(6, 18)), 'pagi')
666
  if fig7 is not None:
667
  st.plotly_chart(fig7, use_container_width=True)
668
  else:
 
673
  st.markdown('<div style="text-align:center; font-weight:bold; margin-bottom: 8px;">Position 4 (18:00–06:00)</div>', unsafe_allow_html=True)
674
  pos4_data = alarm_data[alarm_data['Position'] == 4].copy()
675
  pos4_data = pos4_data[~pos4_data['hour'].between(6, 17, inclusive='both')]
676
+ fig8 = create_radial_chart(pos4_data, "", list(range(18, 24)) + list(range(0, 6)), 'sore')
677
  if fig8 is not None:
678
  st.plotly_chart(fig8, use_container_width=True)
679
  else: