1+ # Bokeh libraries
2+ from bokeh .plotting import figure , show
3+ from bokeh .models import ColumnDataSource , CDSView , GroupFilter
4+
5+ # Create a ColumnDataSource
6+ standings_cds = ColumnDataSource (standings )
7+
8+ # Create the views for each team
9+ celtics_view = CDSView (source = standings_cds ,
10+ filters = [GroupFilter (column_name = 'teamAbbr' ,
11+ group = 'BOS' )])
12+
13+ raptors_view = CDSView (source = standings_cds ,
14+ filters = [GroupFilter (column_name = 'teamAbbr' ,
15+ group = 'TOR' )])
16+
17+ rockets_view = CDSView (source = standings_cds ,
18+ filters = [GroupFilter (column_name = 'teamAbbr' ,
19+ group = 'HOU' )])
20+ warriors_view = CDSView (source = standings_cds ,
21+ filters = [GroupFilter (column_name = 'teamAbbr' ,
22+ group = 'GS' )])
23+
24+ # Create and configure the figure
25+ east_fig = figure (x_axis_type = 'datetime' ,
26+ plot_height = 300 ,
27+ x_axis_label = 'Date' ,
28+ y_axis_label = 'Wins' ,
29+ toolbar_location = None )
30+
31+ west_fig = figure (x_axis_type = 'datetime' ,
32+ plot_height = 300 ,
33+ x_axis_label = 'Date' ,
34+ y_axis_label = 'Wins' ,
35+ toolbar_location = None )
36+
37+ # Configure the figures for each conference
38+ east_fig .step ('stDate' , 'gameWon' ,
39+ color = '#007A33' , legend = 'Celtics' ,
40+ source = standings_cds , view = celtics_view )
41+ east_fig .step ('stDate' , 'gameWon' ,
42+ color = '#CE1141' , legend = 'Raptors' ,
43+ source = standings_cds , view = raptors_view )
44+
45+ west_fig .step ('stDate' , 'gameWon' , color = '#CE1141' , legend = 'Rockets' ,
46+ source = standings_cds , view = rockets_view )
47+ west_fig .step ('stDate' , 'gameWon' , color = '#006BB6' , legend = 'Warriors' ,
48+ source = standings_cds , view = warriors_view )
49+
50+ # Move the legend to the upper left corner
51+ east_fig .legend .location = 'top_left'
52+ west_fig .legend .location = 'top_left'
0 commit comments