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 -6
View File
@@ -11,7 +11,7 @@ import streamlit as st
from dashboard.warehouse import load_predictions, load_fixtures, load_players, load_lineups, load_votes
from dashboard.viz.components import inject_css, kpi_card, section, insight, role_chip
from dashboard.viz.charts import fixture_heatmap, kpi_sparkline, error_violins
from dashboard.viz.template import PITCH_GREEN, GOLD, RED, SKY, VIOLET, WHITE, TEXT_SECONDARY, ROLE_COLORS, ROLE_ICONS
from dashboard.viz.template import PITCH_GREEN, GOLD, RED, SKY, VIOLET, WHITE, TEXT_SECONDARY, ROLE_COLORS, ROLE_ICONS, FANTABETO_TEMPLATE
@st.cache_data(ttl=3600)
@@ -87,7 +87,7 @@ def run():
), unsafe_allow_html=True)
with k4:
st.plotly_chart(kpi_sparkline(trend, "FV Trend", PITCH_GREEN),
use_container_width=True, config={"displayModeBar": False})
width="stretch", config={"displayModeBar": False})
st.caption("Last 5 GW trend")
st.divider()
@@ -98,7 +98,7 @@ def run():
section("📅 Fixture Difficulty")
heatmap_df = _build_fixture_heatmap(players, fixtures)
fig = fixture_heatmap(heatmap_df)
st.plotly_chart(fig, use_container_width=True)
st.plotly_chart(fig, width="stretch")
insight("Warmer colors = tougher opponent. Based on opponent avg FV from 25/26.")
with c2:
@@ -132,7 +132,7 @@ def run():
]
show.columns = ["Player", "Role", "Team", "H/A", "Opponent", "Projected FV", "Status"]
st.dataframe(
show, use_container_width=True, hide_index=True,
show, width="stretch", hide_index=True,
column_config={
"Player": st.column_config.TextColumn(width="medium"),
"Projected FV": st.column_config.TextColumn(width="small"),
@@ -151,7 +151,6 @@ def run():
ranks = list(np.cumsum(np.diff([8] + ranks, prepend=8).clip(-2, 2)))
import plotly.graph_objects as go
from dashboard.viz.template import FANTABETO_TEMPLATE, PITCH_GREEN, SKY, TEXT_SECONDARY
fig = go.Figure()
fig.add_trace(go.Scatter(
@@ -167,7 +166,7 @@ def run():
xaxis=dict(title=""),
margin=dict(l=10, r=10, t=10, b=10),
)
st.plotly_chart(fig, use_container_width=True)
st.plotly_chart(fig, width="stretch")
if __name__ == "__main__":