Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,34 +17,41 @@ st.markdown(
|
|
| 17 |
"""
|
| 18 |
<style>
|
| 19 |
.stApp {
|
| 20 |
-
background-image: url("https://
|
| 21 |
background-size: cover;
|
| 22 |
background-repeat: no-repeat;
|
| 23 |
background-attachment: fixed;
|
| 24 |
-
background-color: rgba(0, 0, 0, 0.
|
| 25 |
-
color: #ffffff;
|
| 26 |
}
|
| 27 |
.sidebar .sidebar-content {
|
| 28 |
background: linear-gradient(180deg, #1e3c72, #2a5298);
|
| 29 |
border-radius: 10px;
|
| 30 |
padding: 20px;
|
| 31 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
|
|
|
|
| 32 |
}
|
| 33 |
h1 {
|
| 34 |
-
color: #ffcc00;
|
| 35 |
-
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.
|
| 36 |
font-size: 48px;
|
| 37 |
text-align: center;
|
| 38 |
}
|
| 39 |
h2 {
|
| 40 |
-
color: #4caf50;
|
|
|
|
| 41 |
font-size: 32px;
|
| 42 |
margin-top: 20px;
|
| 43 |
}
|
| 44 |
h3 {
|
| 45 |
-
color: #ff5733;
|
|
|
|
| 46 |
font-size: 24px;
|
| 47 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
.stButton>button {
|
| 49 |
background-color: #ff5733;
|
| 50 |
color: white;
|
|
@@ -63,7 +70,10 @@ st.markdown(
|
|
| 63 |
padding: 20px;
|
| 64 |
margin: 10px 0;
|
| 65 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
| 66 |
-
color: #333;
|
|
|
|
|
|
|
|
|
|
| 67 |
}
|
| 68 |
</style>
|
| 69 |
""",
|
|
@@ -200,17 +210,17 @@ if option == "Team Info" and team_info:
|
|
| 200 |
fig_donut.update_traces(textinfo='percent+label', pull=[0.1, 0, 0])
|
| 201 |
st.plotly_chart(fig_donut, use_container_width=True)
|
| 202 |
|
| 203 |
-
# Radar Chart
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
st.plotly_chart(
|
| 214 |
st.markdown("</div>", unsafe_allow_html=True)
|
| 215 |
|
| 216 |
elif option == "Team Stats Comparison" and selected_teams_stats:
|
|
@@ -312,21 +322,20 @@ elif option == "Player Stats" and selected_player:
|
|
| 312 |
fig_bar.update_layout(transition_duration=500)
|
| 313 |
st.plotly_chart(fig_bar, use_container_width=True)
|
| 314 |
with col2:
|
| 315 |
-
|
| 316 |
avg_col = get_batting_avg_column(player_batting)
|
| 317 |
-
|
| 318 |
-
radar_values = [player_batting['Runs'].mean(), player_batting['SR'].mean()]
|
| 319 |
if avg_col:
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
st.plotly_chart(
|
| 330 |
fig_donut = px.pie(player_batting, values='Runs', names='Format', title="Runs Distribution",
|
| 331 |
hole=0.4, color_discrete_sequence=px.colors.qualitative.T10)
|
| 332 |
fig_donut.update_traces(textinfo='percent+label')
|
|
@@ -364,25 +373,25 @@ elif option == "Player Comparison" and player1 and player2:
|
|
| 364 |
bat2, bowl2 = get_player_data(player2)
|
| 365 |
|
| 366 |
st.markdown("<div class='card'>", unsafe_allow_html=True)
|
| 367 |
-
#
|
| 368 |
-
st.markdown("<h3>Batting
|
| 369 |
-
|
|
|
|
|
|
|
| 370 |
for player, bat in [(player1, bat1), (player2, bat2)]:
|
| 371 |
if not bat.empty:
|
|
|
|
| 372 |
avg_col = get_batting_avg_column(bat)
|
| 373 |
-
radar_metrics = ['Runs', 'SR']
|
| 374 |
-
radar_values = [bat['Runs'].mean(), bat['SR'].mean()]
|
| 375 |
if avg_col:
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
st.plotly_chart(fig_radar, use_container_width=True)
|
| 386 |
|
| 387 |
# Bowling Bar Chart
|
| 388 |
st.markdown("<h3>Bowling Bar Chart</h3>", unsafe_allow_html=True)
|
|
|
|
| 17 |
"""
|
| 18 |
<style>
|
| 19 |
.stApp {
|
| 20 |
+
background-image: url("https://images.unsplash.com/photo-1587282022844-3146b57d8a36?ixlib=rb-4.0.3&auto=format&fit=crop&w=1920&q=80");
|
| 21 |
background-size: cover;
|
| 22 |
background-repeat: no-repeat;
|
| 23 |
background-attachment: fixed;
|
| 24 |
+
background-color: rgba(0, 0, 0, 0.6); /* Darker overlay for text contrast */
|
| 25 |
+
color: #ffffff; /* White text globally */
|
| 26 |
}
|
| 27 |
.sidebar .sidebar-content {
|
| 28 |
background: linear-gradient(180deg, #1e3c72, #2a5298);
|
| 29 |
border-radius: 10px;
|
| 30 |
padding: 20px;
|
| 31 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
|
| 32 |
+
color: #ffffff;
|
| 33 |
}
|
| 34 |
h1 {
|
| 35 |
+
color: #ffcc00; /* Bright yellow for main headings */
|
| 36 |
+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
|
| 37 |
font-size: 48px;
|
| 38 |
text-align: center;
|
| 39 |
}
|
| 40 |
h2 {
|
| 41 |
+
color: #4caf50; /* Green for subheadings */
|
| 42 |
+
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
|
| 43 |
font-size: 32px;
|
| 44 |
margin-top: 20px;
|
| 45 |
}
|
| 46 |
h3 {
|
| 47 |
+
color: #ff5733; /* Orange for sub-subheadings */
|
| 48 |
+
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
|
| 49 |
font-size: 24px;
|
| 50 |
}
|
| 51 |
+
p, div, span, label, select, option {
|
| 52 |
+
color: #ffffff !important; /* Ensure all text is white */
|
| 53 |
+
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
|
| 54 |
+
}
|
| 55 |
.stButton>button {
|
| 56 |
background-color: #ff5733;
|
| 57 |
color: white;
|
|
|
|
| 70 |
padding: 20px;
|
| 71 |
margin: 10px 0;
|
| 72 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
| 73 |
+
color: #333; /* Dark text inside cards for contrast */
|
| 74 |
+
}
|
| 75 |
+
.card p, .card div, .card span {
|
| 76 |
+
color: #333 !important; /* Override white text inside cards */
|
| 77 |
}
|
| 78 |
</style>
|
| 79 |
""",
|
|
|
|
| 210 |
fig_donut.update_traces(textinfo='percent+label', pull=[0.1, 0, 0])
|
| 211 |
st.plotly_chart(fig_donut, use_container_width=True)
|
| 212 |
|
| 213 |
+
# Grouped Bar Chart (replacing Radar Chart)
|
| 214 |
+
st.markdown("<h3>Format-wise Metrics Comparison</h3>", unsafe_allow_html=True)
|
| 215 |
+
metrics_df = team_stats[['Format', 'Mat', 'Won', 'Lost', 'W/L']].melt(id_vars='Format',
|
| 216 |
+
var_name='Metric',
|
| 217 |
+
value_name='Value')
|
| 218 |
+
fig_grouped_bar = px.bar(metrics_df, x='Format', y='Value', color='Metric', barmode='group',
|
| 219 |
+
title="Team Metrics by Format",
|
| 220 |
+
color_discrete_sequence=px.colors.qualitative.Set1,
|
| 221 |
+
text_auto=True)
|
| 222 |
+
fig_grouped_bar.update_layout(transition_duration=500, showlegend=True)
|
| 223 |
+
st.plotly_chart(fig_grouped_bar, use_container_width=True)
|
| 224 |
st.markdown("</div>", unsafe_allow_html=True)
|
| 225 |
|
| 226 |
elif option == "Team Stats Comparison" and selected_teams_stats:
|
|
|
|
| 322 |
fig_bar.update_layout(transition_duration=500)
|
| 323 |
st.plotly_chart(fig_bar, use_container_width=True)
|
| 324 |
with col2:
|
| 325 |
+
st.markdown("<h3>Batting Metrics Comparison</h3>", unsafe_allow_html=True)
|
| 326 |
avg_col = get_batting_avg_column(player_batting)
|
| 327 |
+
metrics = ['Runs', 'SR']
|
|
|
|
| 328 |
if avg_col:
|
| 329 |
+
metrics.append('Average')
|
| 330 |
+
metrics_df = player_batting[metrics + ['Format']].melt(id_vars='Format',
|
| 331 |
+
var_name='Metric',
|
| 332 |
+
value_name='Value')
|
| 333 |
+
fig_grouped_bar = px.bar(metrics_df, x='Format', y='Value', color='Metric', barmode='group',
|
| 334 |
+
title="Batting Metrics by Format",
|
| 335 |
+
color_discrete_sequence=px.colors.qualitative.Set1,
|
| 336 |
+
text_auto=True)
|
| 337 |
+
fig_grouped_bar.update_layout(transition_duration=500, showlegend=True)
|
| 338 |
+
st.plotly_chart(fig_grouped_bar, use_container_width=True)
|
| 339 |
fig_donut = px.pie(player_batting, values='Runs', names='Format', title="Runs Distribution",
|
| 340 |
hole=0.4, color_discrete_sequence=px.colors.qualitative.T10)
|
| 341 |
fig_donut.update_traces(textinfo='percent+label')
|
|
|
|
| 373 |
bat2, bowl2 = get_player_data(player2)
|
| 374 |
|
| 375 |
st.markdown("<div class='card'>", unsafe_allow_html=True)
|
| 376 |
+
# Grouped Bar Chart (replacing Radar Chart)
|
| 377 |
+
st.markdown("<h3>Batting Metrics Comparison</h3>", unsafe_allow_html=True)
|
| 378 |
+
avg_col1 = get_batting_avg_column(bat1)
|
| 379 |
+
avg_col2 = get_batting_avg_column(bat2)
|
| 380 |
+
metrics_data = []
|
| 381 |
for player, bat in [(player1, bat1), (player2, bat2)]:
|
| 382 |
if not bat.empty:
|
| 383 |
+
player_data = {'Player': player, 'Runs': bat['Runs'].mean(), 'SR': bat['SR'].mean()}
|
| 384 |
avg_col = get_batting_avg_column(bat)
|
|
|
|
|
|
|
| 385 |
if avg_col:
|
| 386 |
+
player_data['Average'] = bat[avg_col].mean()
|
| 387 |
+
metrics_data.append(player_data)
|
| 388 |
+
metrics_df = pd.DataFrame(metrics_data).melt(id_vars='Player', var_name='Metric', value_name='Value')
|
| 389 |
+
fig_grouped_bar = px.bar(metrics_df, x='Player', y='Value', color='Metric', barmode='group',
|
| 390 |
+
title="Batting Metrics Comparison",
|
| 391 |
+
color_discrete_sequence=px.colors.qualitative.Plotly,
|
| 392 |
+
text_auto=True)
|
| 393 |
+
fig_grouped_bar.update_layout(transition_duration=500, showlegend=True)
|
| 394 |
+
st.plotly_chart(fig_grouped_bar, use_container_width=True)
|
|
|
|
| 395 |
|
| 396 |
# Bowling Bar Chart
|
| 397 |
st.markdown("<h3>Bowling Bar Chart</h3>", unsafe_allow_html=True)
|