James McCool commited on
Commit
1fb320e
·
1 Parent(s): 326a55d

Implement consistent task-based color mapping in game rotation timeline plots

Browse files
Files changed (1) hide show
  1. app.py +46 -2
app.py CHANGED
@@ -700,6 +700,28 @@ with tab5:
700
 
701
  # Create figure
702
  fig = go.Figure()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
703
 
704
  # Add bars for each shift
705
  for idx, row in check_rotation.iterrows():
@@ -711,7 +733,7 @@ with tab5:
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)]
715
  ))
716
 
717
  # Update layout
@@ -758,6 +780,28 @@ with tab5:
758
 
759
  # Create figure
760
  fig = go.Figure()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
761
 
762
  # Add bars for each rotation shift
763
  for idx, row in check_rotation.iterrows():
@@ -769,7 +813,7 @@ with tab5:
769
  text=f"{row['minutes']:.1f} Minutes",
770
  textposition='inside',
771
  showlegend=False,
772
- marker_color=px.colors.qualitative.Plotly[hash(row['PLAYER_NAME']) % len(px.colors.qualitative.Plotly)]
773
  ))
774
 
775
  # Update layout
 
700
 
701
  # Create figure
702
  fig = go.Figure()
703
+
704
+ distinct_colors = [
705
+ '#1f77b4', # blue
706
+ '#ff7f0e', # orange
707
+ '#2ca02c', # green
708
+ '#d62728', # red
709
+ '#9467bd', # purple
710
+ '#8c564b', # brown
711
+ '#e377c2', # pink
712
+ '#7f7f7f', # gray
713
+ '#bcbd22', # yellow-green
714
+ '#17becf', # cyan
715
+ '#aec7e8', # light blue
716
+ '#ffbb78', # light orange
717
+ '#98df8a', # light green
718
+ '#ff9896', # light red
719
+ '#c5b0d5' # light purple
720
+ ]
721
+
722
+ # Create a mapping of unique tasks to colors
723
+ unique_tasks = check_rotation['Task'].unique()
724
+ color_map = dict(zip(unique_tasks, distinct_colors[:len(unique_tasks)]))
725
 
726
  # Add bars for each shift
727
  for idx, row in check_rotation.iterrows():
 
733
  text=f"{row['delta']:.1f} Minutes",
734
  textposition='inside',
735
  showlegend=False,
736
+ marker_color=color_map[row['Task']] # Use mapped color for task
737
  ))
738
 
739
  # Update layout
 
780
 
781
  # Create figure
782
  fig = go.Figure()
783
+
784
+ distinct_colors = [
785
+ '#1f77b4', # blue
786
+ '#ff7f0e', # orange
787
+ '#2ca02c', # green
788
+ '#d62728', # red
789
+ '#9467bd', # purple
790
+ '#8c564b', # brown
791
+ '#e377c2', # pink
792
+ '#7f7f7f', # gray
793
+ '#bcbd22', # yellow-green
794
+ '#17becf', # cyan
795
+ '#aec7e8', # light blue
796
+ '#ffbb78', # light orange
797
+ '#98df8a', # light green
798
+ '#ff9896', # light red
799
+ '#c5b0d5' # light purple
800
+ ]
801
+
802
+ # Create a mapping of unique tasks to colors
803
+ unique_tasks = check_rotation['Task'].unique()
804
+ color_map = dict(zip(unique_tasks, distinct_colors[:len(unique_tasks)]))
805
 
806
  # Add bars for each rotation shift
807
  for idx, row in check_rotation.iterrows():
 
813
  text=f"{row['minutes']:.1f} Minutes",
814
  textposition='inside',
815
  showlegend=False,
816
+ marker_color=color_map[row['Task']] # Use mapped color for task
817
  ))
818
 
819
  # Update layout