Spaces:
Runtime error
Runtime error
James McCool
commited on
Commit
·
1130418
1
Parent(s):
0c5282a
Enhance game rotation timeline plot with improved sorting, bar visualization, and quarter markers
Browse files
app.py
CHANGED
@@ -708,7 +708,7 @@ with tab5:
|
|
708 |
y=[row['Task']],
|
709 |
base=row['Start'], # Start position of bar
|
710 |
orientation='h',
|
711 |
-
text=f"{row['delta']:.1f}",
|
712 |
textposition='inside',
|
713 |
showlegend=False,
|
714 |
marker_color=px.colors.qualitative.Plotly[hash(row['PLAYER_NAME']) % len(px.colors.qualitative.Plotly)]
|
@@ -752,18 +752,43 @@ with tab5:
|
|
752 |
display = st.container()
|
753 |
stats_disp = st.container()
|
754 |
check_rotation = working_data[working_data['backlog_lookup'] == game_id_var]
|
755 |
-
check_rotation =
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
764 |
fig.add_vline(x=12, line_width=3, line_dash="dash", line_color="green")
|
765 |
fig.add_vline(x=24, line_width=3, line_dash="dash", line_color="green")
|
766 |
fig.add_vline(x=36, line_width=3, line_dash="dash", line_color="green")
|
|
|
|
|
|
|
|
|
767 |
# pages = pages.set_index('Player')
|
768 |
display.plotly_chart(fig, use_container_width=True)
|
769 |
stats_disp.dataframe(game_rot_stats.style.format(precision=2), hide_index=True, use_container_width = True)
|
|
|
708 |
y=[row['Task']],
|
709 |
base=row['Start'], # Start position of bar
|
710 |
orientation='h',
|
711 |
+
text=f"{row['delta']:.1f} Minutes",
|
712 |
textposition='inside',
|
713 |
showlegend=False,
|
714 |
marker_color=px.colors.qualitative.Plotly[hash(row['PLAYER_NAME']) % len(px.colors.qualitative.Plotly)]
|
|
|
752 |
display = st.container()
|
753 |
stats_disp = st.container()
|
754 |
check_rotation = working_data[working_data['backlog_lookup'] == game_id_var]
|
755 |
+
check_rotation = team_backlog.sort_values(by=['GAME_DATE', 'Finish'], ascending=[False, True])
|
756 |
+
|
757 |
+
fig = go.Figure()
|
758 |
+
|
759 |
+
# Add bars for each shift
|
760 |
+
for idx, row in check_rotation.iterrows():
|
761 |
+
fig.add_trace(go.Bar(
|
762 |
+
x=[row['minutes']], # Width of bar
|
763 |
+
y=[row['Task']],
|
764 |
+
base=row['Start'], # Start position of bar
|
765 |
+
orientation='h',
|
766 |
+
text=f"{row['minutes']:.1f} Minutes",
|
767 |
+
textposition='inside',
|
768 |
+
showlegend=False,
|
769 |
+
marker_color=px.colors.qualitative.Plotly[hash(row['PLAYER_NAME']) % len(px.colors.qualitative.Plotly)]
|
770 |
+
))
|
771 |
+
|
772 |
+
# Update layout
|
773 |
+
fig.update_layout(
|
774 |
+
barmode='overlay',
|
775 |
+
xaxis=dict(
|
776 |
+
range=[0, 48],
|
777 |
+
title='Game Time (minutes)'
|
778 |
+
),
|
779 |
+
yaxis=dict(
|
780 |
+
autorange='reversed'
|
781 |
+
)
|
782 |
+
)
|
783 |
+
|
784 |
+
# Add quarter lines
|
785 |
fig.add_vline(x=12, line_width=3, line_dash="dash", line_color="green")
|
786 |
fig.add_vline(x=24, line_width=3, line_dash="dash", line_color="green")
|
787 |
fig.add_vline(x=36, line_width=3, line_dash="dash", line_color="green")
|
788 |
+
|
789 |
+
game_rot_stats = check_rotation.reindex(game_rot_cols,axis="columns")
|
790 |
+
game_rot_stats = game_rot_stats.drop_duplicates(subset='PLAYER_NAME')
|
791 |
+
|
792 |
# pages = pages.set_index('Player')
|
793 |
display.plotly_chart(fig, use_container_width=True)
|
794 |
stats_disp.dataframe(game_rot_stats.style.format(precision=2), hide_index=True, use_container_width = True)
|