Fix Players page KeyError + use_container_width deprecation

- Players page: fix regression_chart xg_col default (goals_p90 -> xg_p90)
- charts.py: make regression_chart defensive against missing columns
- All pages: replace use_container_width=True with width='stretch'
- Verified: all 5 pages render with zero errors via Playwright browser test
This commit is contained in:
ramseshk
2026-08-11 15:24:39 +08:00
parent 397078d635
commit 30d676517e
5 changed files with 25 additions and 23 deletions
+5 -5
View File
@@ -108,7 +108,7 @@ def run():
section("📊 Percentile Radar")
role_avg = players[players["role"] == role].mean(numeric_only=True)
fig = percentile_radar(p, RADAR_METRICS, RADAR_LABELS, role_avg)
st.plotly_chart(fig, use_container_width=True)
st.plotly_chart(fig, width="stretch")
insight("Values normalized vs league average for same role. Outer = better.")
with r2:
@@ -119,7 +119,7 @@ def run():
"games_season": p.get("games_season", 1),
}])
fig = regression_chart(pdf, selected)
st.plotly_chart(fig, use_container_width=True)
st.plotly_chart(fig, width="stretch")
div = p.get("goals_season", 0) - (p.get("xg_p90", 0) or 0) * p.get("games_season", 1)
div_label = "overperforming" if div > 1 else ("underperforming" if div < -1 else "on par with")
insight(f"{selected} is {div_label} xG by {abs(div):.1f} goals.")
@@ -135,13 +135,13 @@ def run():
yellow = p.get("yellow_season", 0)
red_c = p.get("red_season", 0)
fig = bonus_donut(goals_26, assists_26, yellow * 0.5 + red_c * 1.0)
st.plotly_chart(fig, use_container_width=True)
st.plotly_chart(fig, width="stretch")
insight(f"Season totals: {goals_26:.0f}G + {assists_26:.0f}A — {yellow:.0f}🟨 {red_c:.0f}🟥")
with b2:
section("⚠️ Card Risk Gauge")
fig = card_gauge(p.get("yellow_per_game", 0), p.get("red_per_game", 0))
st.plotly_chart(fig, use_container_width=True)
st.plotly_chart(fig, width="stretch")
ypg = p.get("yellow_per_game", 0)
if ypg > 0.2:
insight(f"⚠️ High yellow risk: {ypg:.2f} per game. Consider rotation in tough fixtures.")
@@ -163,7 +163,7 @@ def run():
"matchday", "vote", "goals", "fantavote"
]].sort_values("matchday", ascending=False)
recent.columns = ["Matchday", "Vote", "Goals", "Fantavote"]
st.dataframe(recent, use_container_width=True, hide_index=True)
st.dataframe(recent, width="stretch", hide_index=True)
if __name__ == "__main__":