Spaces:
Running
Running
James McCool
commited on
Commit
·
f3f1aff
1
Parent(s):
a5c1797
Adding info for stints to hover box on Gantt chart.
Browse files- src/streamlit_app.py +36 -6
src/streamlit_app.py
CHANGED
|
@@ -754,6 +754,21 @@ if selected_tab == 'Game Rotations':
|
|
| 754 |
|
| 755 |
# Add bars for each shift
|
| 756 |
for idx, row in check_rotation.iterrows():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 757 |
fig.add_trace(go.Bar(
|
| 758 |
x=[row['delta']], # Width of bar
|
| 759 |
y=[row['Task']],
|
|
@@ -762,7 +777,8 @@ if selected_tab == 'Game Rotations':
|
|
| 762 |
text=f"{row['delta']:.1f} Minutes",
|
| 763 |
textposition='inside',
|
| 764 |
showlegend=False,
|
| 765 |
-
marker_color=px.colors.qualitative.Plotly[hash(row['PLAYER_NAME']) % len(px.colors.qualitative.Plotly)]
|
|
|
|
| 766 |
))
|
| 767 |
|
| 768 |
# Update layout
|
|
@@ -782,9 +798,8 @@ if selected_tab == 'Game Rotations':
|
|
| 782 |
fig.add_vline(x=24, line_width=3, line_dash="dash", line_color="green")
|
| 783 |
fig.add_vline(x=36, line_width=3, line_dash="dash", line_color="green")
|
| 784 |
|
| 785 |
-
# Dynamically build columns list based on what exists in data
|
| 786 |
available_cols = [col for col in game_rot_cols_base if col in check_rotation.columns]
|
| 787 |
-
available_cols += [col for col in game_rot_cols_stint if col in check_rotation.columns]
|
| 788 |
game_rot_stats = check_rotation.reindex(available_cols, axis="columns")
|
| 789 |
game_rot_stats = game_rot_stats.drop_duplicates(subset='backlog_lookup')
|
| 790 |
|
|
@@ -806,9 +821,8 @@ if selected_tab == 'Game Rotations':
|
|
| 806 |
stats_disp = st.container()
|
| 807 |
check_rotation = working_data[working_data['backlog_lookup'] == game_id_var]
|
| 808 |
check_rotation = check_rotation.sort_values(by='Start', ascending=True)
|
| 809 |
-
# Dynamically build columns list based on what exists in data
|
| 810 |
available_cols = [col for col in game_rot_cols_base if col in check_rotation.columns]
|
| 811 |
-
available_cols += [col for col in game_rot_cols_stint if col in check_rotation.columns]
|
| 812 |
game_rot_stats = check_rotation.reindex(available_cols, axis="columns")
|
| 813 |
game_rot_stats = game_rot_stats.drop_duplicates(subset='PLAYER_NAME')
|
| 814 |
|
|
@@ -839,6 +853,21 @@ if selected_tab == 'Game Rotations':
|
|
| 839 |
|
| 840 |
# Add bars for each rotation shift
|
| 841 |
for idx, row in check_rotation.iterrows():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 842 |
fig.add_trace(go.Bar(
|
| 843 |
x=[row['Finish'] - row['Start']], # Width of bar
|
| 844 |
y=[row['Task']],
|
|
@@ -847,7 +876,8 @@ if selected_tab == 'Game Rotations':
|
|
| 847 |
text=f"{row['minutes']:.1f} Minutes",
|
| 848 |
textposition='inside',
|
| 849 |
showlegend=False,
|
| 850 |
-
marker_color=color_map[row['Task']] # Use mapped color for task
|
|
|
|
| 851 |
))
|
| 852 |
|
| 853 |
# Update layout
|
|
|
|
| 754 |
|
| 755 |
# Add bars for each shift
|
| 756 |
for idx, row in check_rotation.iterrows():
|
| 757 |
+
# Build hover text with stint stats
|
| 758 |
+
hover_text = f"<b>{row['PLAYER_NAME']}</b><br>"
|
| 759 |
+
hover_text += f"Time: {row['Start']:.1f} - {row['Finish']:.1f} ({row['delta']:.1f} min)<br>"
|
| 760 |
+
hover_text += f"<br><b>Stint Stats:</b><br>"
|
| 761 |
+
|
| 762 |
+
# Add stint stats if they exist
|
| 763 |
+
if 'stint_PTS' in row.index and pd.notna(row.get('stint_PTS', None)) and row.get('stint_PTS', 0) != '':
|
| 764 |
+
hover_text += f"PTS: {int(row['stint_PTS'])} | FGM: {int(row.get('stint_FGM', 0))} | FGA: {int(row.get('stint_FGA', 0))}<br>"
|
| 765 |
+
hover_text += f"3PM: {int(row.get('stint_FG3M', 0))} | REB: {int(row.get('stint_REB', 0))} | AST: {int(row.get('stint_AST', 0))}<br>"
|
| 766 |
+
hover_text += f"STL: {int(row.get('stint_STL', 0))} | BLK: {int(row.get('stint_BLK', 0))} | TOV: {int(row.get('stint_TOV', 0))}<br>"
|
| 767 |
+
hover_text += f"PF: {int(row.get('stint_PF', 0))}<br>"
|
| 768 |
+
hover_text += f"<b>Fantasy: {row.get('stint_Fantasy', 0):.1f}</b> | <b>FD: {row.get('stint_FD_Fantasy', 0):.1f}</b>"
|
| 769 |
+
else:
|
| 770 |
+
hover_text += "No stint data available"
|
| 771 |
+
|
| 772 |
fig.add_trace(go.Bar(
|
| 773 |
x=[row['delta']], # Width of bar
|
| 774 |
y=[row['Task']],
|
|
|
|
| 777 |
text=f"{row['delta']:.1f} Minutes",
|
| 778 |
textposition='inside',
|
| 779 |
showlegend=False,
|
| 780 |
+
marker_color=px.colors.qualitative.Plotly[hash(row['PLAYER_NAME']) % len(px.colors.qualitative.Plotly)],
|
| 781 |
+
hovertemplate=hover_text + "<extra></extra>"
|
| 782 |
))
|
| 783 |
|
| 784 |
# Update layout
|
|
|
|
| 798 |
fig.add_vline(x=24, line_width=3, line_dash="dash", line_color="green")
|
| 799 |
fig.add_vline(x=36, line_width=3, line_dash="dash", line_color="green")
|
| 800 |
|
| 801 |
+
# Dynamically build columns list based on what exists in data (stint stats shown in hover only)
|
| 802 |
available_cols = [col for col in game_rot_cols_base if col in check_rotation.columns]
|
|
|
|
| 803 |
game_rot_stats = check_rotation.reindex(available_cols, axis="columns")
|
| 804 |
game_rot_stats = game_rot_stats.drop_duplicates(subset='backlog_lookup')
|
| 805 |
|
|
|
|
| 821 |
stats_disp = st.container()
|
| 822 |
check_rotation = working_data[working_data['backlog_lookup'] == game_id_var]
|
| 823 |
check_rotation = check_rotation.sort_values(by='Start', ascending=True)
|
| 824 |
+
# Dynamically build columns list based on what exists in data (stint stats shown in hover only)
|
| 825 |
available_cols = [col for col in game_rot_cols_base if col in check_rotation.columns]
|
|
|
|
| 826 |
game_rot_stats = check_rotation.reindex(available_cols, axis="columns")
|
| 827 |
game_rot_stats = game_rot_stats.drop_duplicates(subset='PLAYER_NAME')
|
| 828 |
|
|
|
|
| 853 |
|
| 854 |
# Add bars for each rotation shift
|
| 855 |
for idx, row in check_rotation.iterrows():
|
| 856 |
+
# Build hover text with stint stats
|
| 857 |
+
hover_text = f"<b>{row['PLAYER_NAME']}</b><br>"
|
| 858 |
+
hover_text += f"Time: {row['Start']:.1f} - {row['Finish']:.1f} ({row['minutes']:.1f} min)<br>"
|
| 859 |
+
hover_text += f"<br><b>Stint Stats:</b><br>"
|
| 860 |
+
|
| 861 |
+
# Add stint stats if they exist
|
| 862 |
+
if 'stint_PTS' in row.index and pd.notna(row.get('stint_PTS', None)) and row.get('stint_PTS', 0) != '':
|
| 863 |
+
hover_text += f"PTS: {int(row['stint_PTS'])} | FGM: {int(row.get('stint_FGM', 0))} | FGA: {int(row.get('stint_FGA', 0))}<br>"
|
| 864 |
+
hover_text += f"3PM: {int(row.get('stint_FG3M', 0))} | REB: {int(row.get('stint_REB', 0))} | AST: {int(row.get('stint_AST', 0))}<br>"
|
| 865 |
+
hover_text += f"STL: {int(row.get('stint_STL', 0))} | BLK: {int(row.get('stint_BLK', 0))} | TOV: {int(row.get('stint_TOV', 0))}<br>"
|
| 866 |
+
hover_text += f"PF: {int(row.get('stint_PF', 0))}<br>"
|
| 867 |
+
hover_text += f"<b>Fantasy: {row.get('stint_Fantasy', 0):.1f}</b> | <b>FD: {row.get('stint_FD_Fantasy', 0):.1f}</b>"
|
| 868 |
+
else:
|
| 869 |
+
hover_text += "No stint data available"
|
| 870 |
+
|
| 871 |
fig.add_trace(go.Bar(
|
| 872 |
x=[row['Finish'] - row['Start']], # Width of bar
|
| 873 |
y=[row['Task']],
|
|
|
|
| 876 |
text=f"{row['minutes']:.1f} Minutes",
|
| 877 |
textposition='inside',
|
| 878 |
showlegend=False,
|
| 879 |
+
marker_color=color_map[row['Task']], # Use mapped color for task
|
| 880 |
+
hovertemplate=hover_text + "<extra></extra>"
|
| 881 |
))
|
| 882 |
|
| 883 |
# Update layout
|