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:
@@ -112,15 +112,18 @@ def percentile_radar(player_row: pd.Series, metrics: list, labels: list,
|
||||
# ─────────────────────────────────────────────────────────────────
|
||||
|
||||
def regression_chart(df: pd.DataFrame, player: str,
|
||||
xg_col="goals_p90", goal_col="goals_season",
|
||||
xg_col="xg_p90", goal_col="goals_season",
|
||||
games_col="games_season") -> go.Figure:
|
||||
"""Rolling actual goals vs expected with divergence shading.
|
||||
Uses season-level totals as static chart.
|
||||
"""
|
||||
"""Rolling actual goals vs expected with divergence shading."""
|
||||
actual = df[goal_col].iloc[0] if goal_col in df.columns else 0
|
||||
xg_val = df[xg_col].iloc[0] if xg_col in df.columns else 0
|
||||
games = df[games_col].iloc[0] if games_col in df.columns else 1
|
||||
expected = xg_val * 1.2 * games
|
||||
|
||||
fig = go.Figure()
|
||||
fig.add_trace(go.Bar(
|
||||
x=["Actual Goals", "Expected (xG * 1.2)"],
|
||||
y=[df[goal_col].iloc[0], df[xg_col].iloc[0] * 1.2 * df[games_col].iloc[0]],
|
||||
y=[actual, expected],
|
||||
marker_color=[PITCH_GREEN, SKY], texttemplate="%{y:.1f}",
|
||||
textposition="outside", textfont=dict(color=TEXT, size=13),
|
||||
showlegend=False,
|
||||
|
||||
Reference in New Issue
Block a user