-
Notifications
You must be signed in to change notification settings - Fork 1
/
explore.py
654 lines (441 loc) · 22.2 KB
/
explore.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
from bokeh.io import curdoc
from bokeh.plotting import figure, ColumnDataSource
from bokeh.layouts import row, column, widgetbox
from bokeh.models import HoverTool, ResetTool, SaveTool, WheelZoomTool, BoxZoomTool, PanTool, Spacer, Range1d, Legend
from bokeh.models.widgets import Dropdown, Button, RangeSlider, Div, TextInput, Panel, Tabs, DataTable, TableColumn
from bokeh.models.tickers import FixedTicker
from bokeh.palettes import all_palettes
from bokeh.models.callbacks import CustomJS
from espnff import League, PrivateLeagueException, InvalidLeagueException, UnknownLeagueException
from datetime import datetime
from structures import Team
import logging
# hide bokeh warnings, but show errors and above
logging.root.setLevel(logging.ERROR)
def retrieve_lg_info(league_id, year):
# todo docstring
# flag for whether league access was successful
all_good = True
try:
league = League(league_id, year)
# todo function for wrapping with this style
except PrivateLeagueException:
lg_id_message.text = ('<b><p style="color: red;">League not viewable by public. '
'<a href="http://support.espn.com/articles/en_US/FAQ/Making-a-Private-League-'
'Viewable-to-the-Public?section=Fantasy-Football" target="_blank">'
'How to Resolve</a></p></b>')
all_good = False
except InvalidLeagueException:
lg_id_message.text = '<b><p style="color: red;">League with id {} does not exist.</p></b>'.format(league_id)
all_good = False
except UnknownLeagueException:
lg_id_message.text = '<b><p style="color: red;">{} Season for league with id {} does not exist.</p></b>'.format(year, league_id)
all_good = False
if all_good:
lg_id_message.text = '<b><p style="color: #fcbf16;">Compiling data for League {}, \n{} Season</p></b>'.format(league_id, year)
teams = league.teams
number_teams = league.settings.team_count
# not available to just pull from league object
latest_week = teams[0].wins + teams[0].losses
# list of owner names as given by their espn accounts
all_owners = [tm.owner for tm in teams]
# to be used for options in dropdown menus
owners_list_dd = [(owner, owner) for owner in all_owners]
# espnff team objects to retrieve data
all_team_objs = [Team(tm.owner, tm.scores) for tm in teams]
# valid regular season weeks
all_weeks = [i for i in range(1, latest_week + 1)]
# given the name of an owner, returns index where it's found in the team objects list
owner_to_idx_dict = {tm_obj.owner: index for index, tm_obj in enumerate(all_team_objs)}
return league, number_teams, latest_week, all_owners, owners_list_dd, all_team_objs, all_weeks, owner_to_idx_dict
def get_scores(lg_obj, wk_num):
"""Returns a list of each team's owner and score for the selected week
:param lg_obj: a League(league_id, year) object for espnff
:param wk_num: int, week of the season
:return: a list of lists; [[owner, score], ... ] sorted highest to lowest
"""
week_scores = {}
for matchup in lg_obj.scoreboard(week=wk_num):
home = [matchup.home_team, matchup.home_score]
away = [matchup.away_team, matchup.away_score]
week_scores[home[0].owner] = home[1]
week_scores[away[0].owner] = away[1]
# dict to list of lists
scores = map(list, week_scores.items())
# a list of lists [owner, score] for current week, highest to lowest score
return sorted(scores, reverse=True, key=lambda x: x[1])
def get_line_colors(number_teams):
# todo docstring
# todo - this is hacky - refactor
colors = all_palettes['Paired'][number_teams]
colors[0] = '#7fe8cd'
if len(colors) >= 5:
colors[4] = '#828081'
if len(colors) >= 7:
colors[6] = '#000000'
if len(colors) >= 9:
colors[8] = '#592724'
if len(colors) >= 11:
colors[10] = '#0f4c30'
return colors
def initialize_sc_figure(league, curr_week):
# todo docstring
sc_hover = HoverTool(tooltips=[
('Week', '@x'),
('Owner', '@owner'),
('Score', '@y{*00.00}'),
])
# try plotting just scores first
plot = figure(plot_height=600, plot_width=1000,
title='{} - {} Regular Season'.format(league.settings.name, year_input.value),
x_axis_label='Week',
y_axis_label='Scores',
tools=[sc_hover, ResetTool(), BoxZoomTool(), WheelZoomTool(), SaveTool(), PanTool()])
plot.xaxis.ticker = FixedTicker(ticks=[i for i in range(1, curr_week + 1)])
return plot
def initialize_ew_figure(league, curr_week):
# todo docstring
ew_hover = HoverTool(tooltips=[
('Week', '@x'),
('Owner', '@owner'),
('Expected Wins', '@y{*0.000}'),
])
# plotting wins and expected wins in the second tab
plot = figure(plot_height=600, plot_width=1000,
title='{} - {} Regular Season'.format(league.settings.name, year_input.value),
x_axis_label='Week',
y_axis_label='Expected Wins',
tools=[ew_hover, ResetTool(), BoxZoomTool(), WheelZoomTool(), SaveTool(), PanTool()])
plot.xaxis.ticker = FixedTicker(ticks=[i for i in range(1, curr_week + 1)])
return plot
def initialize_ew_table(team_objects, week_number, number_teams):
# todo docstring
table_sources = get_table_sources(team_objects, week_number, number_teams)
table_columns = [
TableColumn(field='rank', title='Rank'),
TableColumn(field='owner', title='Owner'),
TableColumn(field='wins', title='Wins'),
TableColumn(field='ew', title='Expected Wins'),
TableColumn(field='diff', title='Difference')
]
return DataTable(source=table_sources, columns=table_columns, width=600, height=500, sortable=True)
def get_sc_sources(all_weeks, team_objects, all_owners, curr_week, number_teams):
# todo docstring
# scores
# looks awful, but faster than using list.append() for each
sources = [ColumnDataSource(dict(
x=all_weeks,
y=team_objects[i].scores[:curr_week],
owner=[all_owners[i]] * len(all_weeks)
)) for i in range(number_teams)]
return sources
def get_ew_sources(all_weeks, team_objects, all_owners, curr_week, number_teams):
# todo docstring
# expected wins
# looks awful, but faster than using list.append() for each
sources = [ColumnDataSource(dict(
x=all_weeks,
y=team_objects[i].exp_wins[1:curr_week + 1],
owner=[all_owners[i]] * len(all_weeks)
)) for i in range(number_teams)]
return sources
def get_table_sources(team_objects, curr_week, number_teams):
# todo docstring
teams_by_ew = sorted(team_objects, key=lambda x: x.exp_wins[curr_week], reverse=True)
owners_wins = {team.owner: team.wins for team in league_obj.teams}
rankings = [1] * number_teams
rank = 1
for idx in range(number_teams):
not_first_index = idx != 0
this_team_ew = round(teams_by_ew[idx].exp_wins[curr_week], 5)
prev_team_ew = round(teams_by_ew[idx - 1].exp_wins[curr_week], 5)
if not_first_index and this_team_ew < prev_team_ew:
rank = idx + 1
rankings[idx] = rank
sources = dict(
rank=[rankings[i] for i in range(number_teams)],
owner=[teams_by_ew[i].owner for i in range(number_teams)],
wins=[owners_wins[teams_by_ew[i].owner] for i in range(number_teams)],
ew=[round(teams_by_ew[i].exp_wins[curr_week], 3) for i in range(number_teams)],
diff=[round(owners_wins[teams_by_ew[i].owner] - teams_by_ew[i].exp_wins[curr_week], 3) for i in range(number_teams)]
)
return ColumnDataSource(sources)
def plot_sc_data(team_objects, score_sources, colors):
# todo docstring
sc_rend_list = []
sc_legend_items = []
for idx, tm_obj in enumerate(team_objects):
first_name = tm_obj.owner.split(' ')[0]
r = plot1.rect('x', 'y', source=score_sources[idx], width=.5, height=1.2, fill_color=colors[idx], fill_alpha=0.95,
line_color=colors[idx], muted_color=colors[idx], muted_alpha=0.05, hover_alpha=1,
hover_color=colors[idx], hover_line_alpha=1)
l = plot1.line('x', 'y', source=score_sources[idx], line_color='black', line_alpha=0.08, line_dash='dashed',
muted_color=colors[idx], muted_alpha=0.05, hover_color=colors[idx], hover_alpha=1)
sc_rend_list.append((r, l))
sc_legend_items.append(('{} '.format(first_name), [r, l]))
plot1.legend.location = 'top_center'
plot1.legend.orientation = 'horizontal'
sc_legend = Legend(items=sc_legend_items, location=(0, 13), orientation='horizontal')
plot1.add_layout(sc_legend, 'above')
plot1.legend.click_policy = 'mute'
plot1.legend.border_line_alpha = 0
return sc_rend_list
def plot_ew_data(team_objects, exp_wins_sources, colors):
# todo docstring
ew_rend_list = []
ew_legend_items = []
for idx, tm_obj in enumerate(team_objects):
f_name = tm_obj.owner.split(' ')[0]
l = plot2.line('x', 'y', source=exp_wins_sources[idx], line_color=colors[idx], line_alpha=0.95,
muted_color=colors[idx], muted_alpha=0.05, line_width=1.5)
x = plot2.square('x', 'y', size=4, source=exp_wins_sources[idx], fill_color=colors[idx], line_alpha=0.95,
muted_color=colors[idx], muted_alpha=0.05, line_color=colors[idx], line_width=1.5)
ew_rend_list.append((l, x))
ew_legend_items.append(('{} '.format(f_name), [l, x]))
plot2.legend.location = 'top_center'
plot2.legend.orientation = 'horizontal'
ew_legend = Legend(items=ew_legend_items, location=(0, 13), orientation='horizontal')
plot2.add_layout(ew_legend, 'above')
plot2.legend.click_policy = 'mute'
plot2.legend.border_line_alpha = 0
return ew_rend_list
def compile_expected_wins(league, team_objects, all_weeks, ownr_to_idx, number_teams):
# todo docstring
# compile expected wins
for week in all_weeks:
all_scores = get_scores(league, week)
for i, (owner, score) in enumerate(all_scores):
tgt_team = team_objects[ownr_to_idx[owner]]
# e.g., 12-team league, 2nd highest scorer would lose one matchup --> 1 - (1 * 1/11) = .909 expected wins
ew_this_week = 1 - (i * (1/(number_teams - 1)))
# determine new expected wins total and store
cumul_ew = tgt_team.exp_wins[week - 1]
new_cumul_ew = cumul_ew + ew_this_week
tgt_team.exp_wins.append(new_cumul_ew)
def league_id_handler(attr, old, new):
# todo docstring
global league_obj, num_teams, week_num, owners, owners_list, team_objs, weeks, owner_to_idx
global plot1, plot2, line_colors, backup_sc_data, backup_ew_data, legend_labels
global sc_sources, ew_sources, sc_renderers, ew_renderers
global layout
league_obj, num_teams, week_num, owners, owners_list, team_objs, weeks, owner_to_idx = retrieve_lg_info(int(new), int(year_input.value))
plot1 = initialize_sc_figure(league_obj, week_num)
plot2 = initialize_ew_figure(league_obj, week_num)
line_colors = get_line_colors(num_teams)
sc_sources = get_sc_sources(weeks, team_objs, owners, week_num, num_teams)
sc_renderers = plot_sc_data(team_objs, sc_sources, line_colors)
compile_expected_wins(league_obj, team_objs, weeks, owner_to_idx, num_teams)
ew_sources = get_ew_sources(weeks, team_objs, owners, week_num, num_teams)
ew_renderers = plot_ew_data(team_objs, ew_sources, line_colors)
# force bokeh to update figures
plot1_wrap.children[0] = plot1
# notify user of success
lg_id_message.text = '<b><p style="color: green;">League accessed successfully.</p></b>'
plot2_wrap.children[0] = plot2
table_wrap.children[0] = initialize_ew_table(team_objs, week_num, num_teams)
# will use to avoid re-computation of data after comparisons
backup_sc_data = [[[], []] for _ in range(num_teams)]
backup_ew_data = [[[], []] for _ in range(num_teams)]
legend_labels = ['' for _ in range(num_teams)]
team1_dd.disabled = False
team2_dd.disabled = False
team1_dd.label = 'Team 1 - Select'
team2_dd.label = 'Team 2 - Select'
team1_dd.menu = owners_list
team2_dd.menu = owners_list
comp_button.button_type = 'danger'
week_slider.end = week_num
week_slider.value = (1, week_num)
def week_slider_handler(attr, old, new):
# todo docstring
start_wk, end_wk = week_slider.value
# don't attempt to filter teams unless two teams are selected
if comp_button.button_type == 'warning':
selected_tm_idxs = [owner_to_idx[str(team1_dd.label)], owner_to_idx[str(team2_dd.label)]]
else:
selected_tm_idxs = [i for i in range(num_teams)]
# values passed from widget are sometimes floats (e.g. 10.0000000002)
start_wk = round(start_wk)
end_wk = round(end_wk)
for i in range(len(sc_renderers)):
if i in selected_tm_idxs:
selected_wks = weeks[start_wk - 1: end_wk]
selected_scores = team_objs[i].scores[start_wk - 1:end_wk]
selected_ew = team_objs[i].exp_wins[start_wk:end_wk + 1]
owner = [owners[i]] * (end_wk - start_wk + 1)
rect_r, sc_line_r = sc_renderers[i]
ew_line_r, x_r = ew_renderers[i]
rect_r.data_source.data = dict(x=selected_wks, y=selected_scores, owner=owner)
sc_line_r.data_source.data = dict(x=selected_wks, y=selected_scores, owner=owner)
ew_line_r.data_source.data = dict(x=selected_wks, y=selected_ew, owner=owner)
x_r.data_source.data = dict(x=selected_wks, y=selected_ew, owner=owner)
def team1_select_handler(attr, old, new):
# todo docstring
team1_dd.label = str(team1_dd.value)
if 'Select' not in team1_dd.label and 'Select' not in team2_dd.label and comp_button.button_type == 'danger':
comp_button.button_type = 'success'
def team2_select_handler(attr, old, new):
# todo docstring
team2_dd.label = str(team2_dd.value)
if 'Select' not in team1_dd.label and 'Select' not in team2_dd.label and comp_button.button_type == 'danger':
comp_button.button_type = 'success'
def compare_button_handler():
# todo docstring
global sc_renderers
global ew_renderers
team1_dd.disabled = True
team2_dd.disabled = True
selected_tm_idxs = [owner_to_idx[str(team1_dd.label)], owner_to_idx[str(team2_dd.label)]]
num_rend = len(sc_renderers)
for i in range(num_rend):
if i not in selected_tm_idxs:
for j in range(2):
# save data to restore when comparison done
backup_sc_data[i][j] = sc_renderers[i][j].data_source.data
backup_ew_data[i][j] = ew_renderers[i][j].data_source.data
# empty data fields hide glyphs from the plot
sc_renderers[i][j].data_source.data = dict(x=[], y=[], owner=[])
ew_renderers[i][j].data_source.data = dict(x=[], y=[], owner=[])
# save label for recovery after comparison
legend_labels[i] = plot1.legend[0].items[i].label
# empty labels for legend items hide entries
plot1.legend[0].items[i].label = None
plot2.legend[0].items[i].label = None
comp_button.button_type = 'warning'
comp_button.label = 'Clear'
def clear_button_handler():
# todo docstring
global sc_renderers
global ew_renderers
selected_tm_idxs = [owner_to_idx[str(team1_dd.label)], owner_to_idx[str(team2_dd.label)]]
num_rend = len(sc_renderers)
for i in range(num_rend):
if i not in selected_tm_idxs:
for j in range(2):
# recover scores, expected wins data
sc_renderers[i][j].data_source.data = backup_sc_data[i][j]
ew_renderers[i][j].data_source.data = backup_ew_data[i][j]
# recover label from before comparison
plot1.legend[0].items[i].label = legend_labels[i]
plot2.legend[0].items[i].label = legend_labels[i]
# layout displays non-comparison state again
team1_dd.label = 'Team 1 - Select'
team2_dd.label = 'Team 2 - Select'
comp_button.button_type = 'danger'
comp_button.label = 'Compare'
# force redraw using weeks slider
user_selection = week_slider.value
week_slider.value = (user_selection[0] + 1, user_selection[1])
week_slider.value = user_selection
team1_dd.disabled = False
team2_dd.disabled = False
def helper_handler():
# todo docstring
# for dual functionality of compare / clear button
button_to_handler = {
'success': compare_button_handler,
'warning': clear_button_handler
}
if comp_button.button_type in ['success', 'warning']:
button_to_handler[comp_button.button_type]()
def season_handler(attr, old, new):
# todo docstring
global league_obj, num_teams, week_num, owners, owners_list, team_objs, weeks, owner_to_idx
global plot1, plot2, line_colors, backup_sc_data, backup_ew_data, legend_labels
global sc_sources, ew_sources, sc_renderers, ew_renderers
global layout
league_id = lg_id_input.value
league_obj, num_teams, week_num, owners, owners_list, team_objs, weeks, owner_to_idx = retrieve_lg_info(league_id, int(new))
plot1 = initialize_sc_figure(league_obj, week_num)
plot2 = initialize_ew_figure(league_obj, week_num)
line_colors = get_line_colors(num_teams)
sc_sources = get_sc_sources(weeks, team_objs, owners, week_num, num_teams)
sc_renderers = plot_sc_data(team_objs, sc_sources, line_colors)
compile_expected_wins(league_obj, team_objs, weeks, owner_to_idx, num_teams)
ew_sources = get_ew_sources(weeks, team_objs, owners, week_num, num_teams)
ew_renderers = plot_ew_data(team_objs, ew_sources, line_colors)
# force bokeh to update figures
plot1_wrap.children[0] = plot1
# notify user of success
lg_id_message.text = '<b><p style="color: green;">League accessed successfully.</p></b>'
plot2_wrap.children[0] = plot2
ew_table = initialize_ew_table(team_objs, week_num, num_teams)
table_wrap.children[0] = ew_table
# will use to avoid re-computation of data after comparisons
backup_sc_data = [[[], []] for _ in range(num_teams)]
backup_ew_data = [[[], []] for _ in range(num_teams)]
legend_labels = ['' for _ in range(num_teams)]
team1_dd.disabled = False
team2_dd.disabled = False
team1_dd.label = 'Team 1 - Select'
team2_dd.label = 'Team 2 - Select'
team1_dd.menu = owners_list
team2_dd.menu = owners_list
comp_button.button_type = 'danger'
week_slider.end = week_num
week_slider.value = (1, week_num)
# TODO add Google Analytics Script here
ga_view_callback = CustomJS(code='''
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-111108475-1', 'auto');
ga('send', 'pageview');
''')
# TODO use callback somewhere
lg_id_input = TextInput(value='1667721', title='League ID (from URL):')
lg_id_message = Div(text='<b><p style="color: green;">League accessed successfully.</p></b>')
september_month = 9
today = datetime.today()
if today.month < september_month:
default_yr = str(today.year - 1)
else:
default_yr = str(today.year)
league_obj, num_teams, week_num, owners, owners_list, team_objs, weeks, owner_to_idx = retrieve_lg_info(int(lg_id_input.value), default_yr)
team1_dd = Dropdown(label='Team 1 - Select', menu=owners_list)
team2_dd = Dropdown(label='Team 2 - Select', menu=owners_list)
comp_button = Button(label='Compare', button_type='danger')
week_slider = RangeSlider(title='Weeks', start=1, end=week_num, value=(1, week_num), step=1)
year_input = TextInput(value=str(default_yr), title='Season:')
plot1 = initialize_sc_figure(league_obj, week_num)
plot2 = initialize_ew_figure(league_obj, week_num)
plot1_wrap = column(children=[plot1])
plot2_wrap = column(children=[plot2])
line_colors = get_line_colors(num_teams)
sc_sources = get_sc_sources(weeks, team_objs, owners, week_num, num_teams)
# will use to avoid re-computation of data after comparisons
backup_sc_data = [[[], []] for _ in range(num_teams)]
backup_ew_data = [[[], []] for _ in range(num_teams)]
legend_labels = ['' for _ in range(num_teams)]
sc_renderers = plot_sc_data(team_objs, sc_sources, line_colors)
compile_expected_wins(league_obj, team_objs, weeks, owner_to_idx, num_teams)
ew_sources = get_ew_sources(weeks, team_objs, owners, week_num, num_teams)
expected_wins_table = initialize_ew_table(team_objs, week_num, num_teams)
table_wrap = column(children=[expected_wins_table])
ew_renderers = plot_ew_data(team_objs, ew_sources, line_colors)
# register callback handlers to respond to changes in widget values
lg_id_input.on_change('value', league_id_handler)
lg_id_input.js_on_change('value', ga_view_callback)
week_slider.on_change('value', week_slider_handler)
team1_dd.on_change('value', team1_select_handler)
team2_dd.on_change('value', team2_select_handler)
comp_button.on_click(helper_handler)
year_input.on_change('value', season_handler)
# arrange layout
tab1 = Panel(child=plot1_wrap, title='Scores')
tab2 = Panel(child=plot2_wrap, title='Expected Wins')
tab3 = Panel(child=table_wrap, title='Summary')
figures = Tabs(tabs=[tab1, tab2, tab3], width=500)
compare_widgets = column(team1_dd, team2_dd, comp_button)
wid_spac1 = Spacer(height=30)
wid_spac2 = Spacer(height=30)
wid_spac3 = Spacer(height=30)
lg_id_message.text = '<b><p style="color: green;">League accessed successfully.</p></b>'
all_widgets = column(lg_id_input, lg_id_message, wid_spac1, compare_widgets, wid_spac2, week_slider, wid_spac3, year_input)
page_title = Div(text="""<strong><h1 style="font-size: 2.5em;">ESPN Fantasy Football League Explorer</h1></strong>""",
width=700, height=50)
main_area = row(all_widgets, figures)
layout = column(page_title, main_area)
curdoc().add_root(layout)
curdoc().title = 'ESPN Fantasy Football League Explorer'