SHELLAPANDIANGANHUNGING commited on
Commit
208a8d1
·
verified ·
1 Parent(s): 30d50ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +106 -0
app.py CHANGED
@@ -1620,6 +1620,112 @@ if not df_issue.empty:
1620
 
1621
  st.markdown("</div>", unsafe_allow_html=True)
1622
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1623
  # =================== 6. ✅ AI INSIGHT ENGINE (BARU - BERDASARKAN DATA & RATIO) ===================
1624
 
1625
  st.markdown("<h3 class='section-title'>OBJECTIVE 7 - Insight and Recommendation</h3>", unsafe_allow_html=True)
 
1620
 
1621
  st.markdown("</div>", unsafe_allow_html=True)
1622
 
1623
+
1624
+ # =================== WHITEBOARD STYLE CHART FOR PANEL 3 ===================
1625
+ st.markdown("<h4 style='text-align: center; color: #2c3e50;'>Whiteboard Insight: Trend vs Frequency</h4>", unsafe_allow_html=True)
1626
+
1627
+ # Buat chart scatter dengan gaya whiteboard
1628
+ if not df_issue.empty:
1629
+ # Ambil data untuk scatter
1630
+ df_plot = df_issue.copy()
1631
+ df_plot['Size'] = df_plot['Avg/Month'] # Ukuran lingkaran = frekuensi (Avg/Month)
1632
+ df_plot['Y'] = df_plot['Trend Slope'] # Y = Trend Slope
1633
+
1634
+ # Buat scatter plot
1635
+ fig = go.Figure()
1636
+
1637
+ # Tambahkan scatter
1638
+ fig.add_trace(go.Scatter(
1639
+ x=df_plot['Category'],
1640
+ y=df_plot['Y'],
1641
+ mode='markers+text',
1642
+ marker=dict(
1643
+ size=df_plot['Size'] * 0.5, # Skala ukuran agar tidak terlalu besar
1644
+ color='#003DA5',
1645
+ line=dict(width=2, color='white'),
1646
+ opacity=0.8
1647
+ ),
1648
+ text=df_plot['Category'],
1649
+ textposition="top center",
1650
+ textfont=dict(size=10, color="#003DA5", family="Arial"),
1651
+ hovertemplate="<b>%{text}</b><br>Trend Slope: %{y:.3f}<br>Avg/Month: %{marker.size:.1f}<extra></extra>",
1652
+ ))
1653
+
1654
+ # Layout
1655
+ fig.update_layout(
1656
+ title=dict(text="<b>Issue Trend vs Frequency (Non-Positive)</b>", x=0.5, y=0.95),
1657
+ xaxis=dict(
1658
+ title="Category",
1659
+ tickangle=45,
1660
+ showgrid=True,
1661
+ gridcolor="#e0e0e0",
1662
+ gridwidth=1,
1663
+ tickfont=dict(size=10, color="#003DA5")
1664
+ ),
1665
+ yaxis=dict(
1666
+ title="Trend Slope",
1667
+ showgrid=True,
1668
+ gridcolor="#e0e0e0",
1669
+ gridwidth=1,
1670
+ tickfont=dict(size=10, color="#003DA5")
1671
+ ),
1672
+ plot_bgcolor="white",
1673
+ paper_bgcolor="white",
1674
+ height=500,
1675
+ margin=dict(t=60, b=60, l=60, r=60),
1676
+ font=dict(family="Arial", size=12, color="#003DA5"),
1677
+ showlegend=False
1678
+ )
1679
+
1680
+ # Tambahkan teks manual seperti whiteboard
1681
+ fig.add_annotation(
1682
+ xref="paper", yref="paper",
1683
+ x=0.05, y=0.95,
1684
+ text="Trend<br>(Slope)",
1685
+ showarrow=False,
1686
+ font=dict(size=12, color="#003DA5"),
1687
+ textangle=-90,
1688
+ align="center"
1689
+ )
1690
+ fig.add_annotation(
1691
+ xref="paper", yref="paper",
1692
+ x=0.5, y=0.05,
1693
+ text="Category",
1694
+ showarrow=False,
1695
+ font=dict(size=12, color="#003DA5"),
1696
+ align="center"
1697
+ )
1698
+ fig.add_annotation(
1699
+ xref="paper", yref="paper",
1700
+ x=0.95, y=0.95,
1701
+ text="<b>Legend of Frequency</b><br>• 10<br>•• 20<br>••• 30<br>•••• 40",
1702
+ showarrow=False,
1703
+ font=dict(size=12, color="#003DA5"),
1704
+ align="left"
1705
+ )
1706
+ fig.add_annotation(
1707
+ xref="paper", yref="paper",
1708
+ x=0.05, y=0.1,
1709
+ text="<b>Semakin tinggi = semakin sering ditemukan deviasi</b><br><b>Semakin besar = semakin banyak ditemukan deviasi</b><br><b>Non-positive</b>",
1710
+ showarrow=False,
1711
+ font=dict(size=12, color="#003DA5"),
1712
+ align="left"
1713
+ )
1714
+
1715
+ st.plotly_chart(fig, use_container_width=True)
1716
+
1717
+ # Insight
1718
+ st.markdown("### 💡 Insight")
1719
+ insight_text = (
1720
+ f"<div class='ai-insight'>"
1721
+ f"The scatter plot visualizes issue categories with 100% coverage and positive trend. "
1722
+ f"Categories higher on the Y-axis indicate stronger upward trends, while larger circles indicate higher average monthly frequency. "
1723
+ f"This helps identify which non-positive issues are both increasing in trend and frequently reported — these should be prioritized for intervention."
1724
+ f"</div>"
1725
+ )
1726
+ st.markdown(insight_text, unsafe_allow_html=True)
1727
+ else:
1728
+ st.info("No data available for non-positive issues with 100% coverage and positive trend.")
1729
  # =================== 6. ✅ AI INSIGHT ENGINE (BARU - BERDASARKAN DATA & RATIO) ===================
1730
 
1731
  st.markdown("<h3 class='section-title'>OBJECTIVE 7 - Insight and Recommendation</h3>", unsafe_allow_html=True)