Private
Public Access
1
0

migration to bokeh 2.2.3

This commit is contained in:
Sander Roosendaal
2020-11-09 10:34:44 +01:00
parent 04be2fc61d
commit 54dc8507db
37 changed files with 171 additions and 145 deletions

View File

@@ -248,7 +248,7 @@ def interactive_hr_piechart(df,rower,title,totalseconds=0):
z.wedge(x=0,y=1, radius=0.4,
start_angle=cumsum('angle',include_zero=True), end_angle=cumsum('angle'),
line_color='white',fill_color='color',source=data,legend='zone')
line_color='white',fill_color='color',source=data,legend_label='zone')
@@ -314,7 +314,7 @@ def interactive_workouttype_piechart(workouts):
p.wedge(x=0, y=1, radius=0.4,
start_angle=cumsum('angle', include_zero=True), end_angle=cumsum('angle'),
line_color="white", fill_color='color', source=data,legend='type', )
line_color="white", fill_color='color', source=data,legend_label='type', )
p.axis.axis_label=None
p.axis.visible=False
@@ -600,7 +600,7 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
window.location.href = links[index]
""")
taptool.callback = callback
taptool.js_on_event('tap',callback)
script,div = components(p)
@@ -779,7 +779,7 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
window.location.href = links[index]
""")
taptool.callback = callback
taptool.js_on_event('tap',callback)
script,div = components(p)
@@ -1451,37 +1451,43 @@ def interactive_forcecurve(theworkouts,workstrokesonly=True,plottype='scatter'):
sourcemultiline.change.emit();
""")
annotation = TextInput(title="Type your plot notes here", value="",
callback=callback)
annotation = TextInput(title="Type your plot notes here", value="")
annotation.js_on_change('value',callback)
callback.args["annotation"] = annotation
slider_spm_min = Slider(start=15.0, end=55,value=15.0, step=.1,
title="Min SPM",callback=callback)
title="Min SPM")
slider_spm_min.js_on_change('value',callback)
callback.args["minspm"] = slider_spm_min
slider_spm_max = Slider(start=15.0, end=55,value=55.0, step=.1,
title="Max SPM",callback=callback)
title="Max SPM")
slider_spm_max.js_on_change('value',callback)
callback.args["maxspm"] = slider_spm_max
slider_work_min = Slider(start=0, end=1500,value=0, step=10,
title="Min Work per Stroke",callback=callback)
title="Min Work per Stroke")
slider_work_min.js_on_change('value',callback)
callback.args["minwork"] = slider_work_min
slider_work_max = Slider(start=0, end=1500,value=1500, step=10,
title="Max Work per Stroke",callback=callback)
title="Max Work per Stroke")
slider_work_max.js_on_change('value',callback)
callback.args["maxwork"] = slider_work_max
distmax = 100+100*int(rowdata['distance'].max()/100.)
slider_dist_min = Slider(start=0,end=distmax,value=0,step=50,
title="Min Distance",callback=callback)
title="Min Distance")
slider_dist_min.js_on_change('value',callback)
callback.args["mindist"] = slider_dist_min
slider_dist_max = Slider(start=0,end=distmax,value=distmax,
step=50,
title="Max Distance",callback=callback)
title="Max Distance")
slider_dist_max.js_on_change('value',callback)
callback.args["maxdist"] = slider_dist_max
layout = layoutrow([layoutcolumn([annotation,
@@ -1619,14 +1625,14 @@ def fitnessmetric_chart(fitnessmetrics,user,workoutmode='rower',startdate=None,
)
plot.circle('date','power2k',source=source,fill_color='red',size=10,
legend='2k power')
legend_label='2k power')
plot.circle('date','power1hr',source=source,fill_color='blue',size=10,
legend='1 hr power')
legend_label='1 hr power')
plot.circle('date','power4min',source=source,fill_color='green',size=10,
legend='4 min power')
legend_label='4 min power')
plot.line('date','power4min',source=source2,color='green')
plot.line('date','power2k',source=source2,color='red')
@@ -1792,8 +1798,8 @@ def interactive_histoall(theworkouts,histoparam,includereststrokes,
annolabel.text = annotation
""")
annotation = TextInput(title="Type your plot notes here", value="",
callback=callback)
annotation = TextInput(title="Type your plot notes here", value="")
annotation.js_on_change('value',callback)
callback.args["annotation"] = annotation
layout = layoutcolumn([annotation,plot])
@@ -2849,15 +2855,15 @@ def interactive_agegroupcpchart(age,normalized=False):
plot.sizing_mode = 'scale_width'
plot.line('duration','fitpowerfh',source=source,
legend='Female HW',color='blue')
legend_label='Female HW',color='blue')
plot.line('duration','fitpowerfl',source=source,
legend='Female LW',color='red')
legend_label='Female LW',color='red')
plot.line('duration','fitpowerml',source=source,
legend='Male LW',color='green')
legend_label='Male LW',color='green')
plot.line('duration','fitpowermh',source=source,
legend='Male HW',color='orange')
legend_label='Male HW',color='orange')
plot.circle('flduration','flpower',source=source,
@@ -2980,7 +2986,7 @@ def interactive_otwcpchart(powerdf,promember=0,rowername="",r=None,cpfit='data',
)
plot.circle('Deltaminutes','CP',source=source,fill_color='red',size=15,
legend='Power Data')
legend_label='Power Data')
plot.xaxis.axis_label = "Duration (minutes)"
plot.yaxis.axis_label = "Power (W)"
@@ -3006,10 +3012,10 @@ def interactive_otwcpchart(powerdf,promember=0,rowername="",r=None,cpfit='data',
hover.mode = 'mouse'
plot.line('duration','CP',source=sourcecomplex,legend="CP Model",
plot.line('duration','CP',source=sourcecomplex,legend_label="CP Model",
color='green')
plot.line('duration','CPmax',source=sourcecomplex,legend="CP Model",
plot.line('duration','CPmax',source=sourcecomplex,legend_label="CP Model",
color='red')
script, div = components(plot)
@@ -3067,7 +3073,7 @@ def interactive_agegroup_plot(df,distance=2000,duration=None,
plot = Figure(tools=TOOLS,plot_width=900)
plot.sizing_mode='scale_width'
plot.circle('age','power',source=source,fill_color='red',size=15,
legend='World Record')
legend_label='World Record')
plot.line(age2,expo_vals)
plot.xaxis.axis_label = "Age"
@@ -3287,7 +3293,7 @@ def interactive_cpchart(rower,thedistances,thesecs,theavpower,
)
plot.circle('duration','power',source=source,fill_color='red',size=15,
legend='Power')
legend_label='Power')
plot.xaxis.axis_label = "Duration (seconds)"
plot.yaxis.axis_label = "Power (W)"
@@ -3334,7 +3340,7 @@ def interactive_cpchart(rower,thedistances,thesecs,theavpower,
plot.circle('duration','power',source=source2,
fill_color='blue',size=3,
legend = 'Power from segments')
legend_label = 'Power from segments')
hover = plot.select(dict(type=HoverTool))
@@ -3352,28 +3358,28 @@ def interactive_cpchart(rower,thedistances,thesecs,theavpower,
plot.legend.orientation = "vertical"
plot.line('duration','power',source=sourcepaul,legend="Paul's Law")
plot.line('duration','power',source=sourcecomplex,legend="CP Model",
plot.line('duration','power',source=sourcepaul,legend_label="Paul's Law")
plot.line('duration','power',source=sourcecomplex,legend_label="CP Model",
color='green')
if p1wc is not None:
plot.line('duration','fitpowerwc',source=sourcecomplex,
legend="World Class",
legend_label="World Class",
color='Maroon',line_dash='dotted')
plot.line('duration','fitpowerexcellent',source=sourcecomplex,
legend="90% percentile",
legend_label="90% percentile",
color='Purple',line_dash='dotted')
plot.line('duration','fitpowergood',source=sourcecomplex,
legend="75% percentile",
legend_label="75% percentile",
color='Olive',line_dash='dotted')
plot.line('duration','fitpowerfair',source=sourcecomplex,
legend="50% percentile",
legend_label="50% percentile",
color='Gray',line_dash='dotted')
plot.line('duration','fitpoweraverage',source=sourcecomplex,
legend="25% percentile",
legend_label="25% percentile",
color='SkyBlue',line_dash='dotted')
@@ -3453,8 +3459,8 @@ def interactive_windchart(id=0,promember=0):
# toolbar_location="below",
toolbar_sticky=False,
)
plot.line('dist','vwind',source=source,legend="Wind Speed (m/s)")
plot.line('dist','tw',source=source,legend="Tail (+)/Head (-) Wind (m/s)",color='black')
plot.line('dist','vwind',source=source,legend_label="Wind Speed (m/s)")
plot.line('dist','tw',source=source,legend_label="Tail (+)/Head (-) Wind (m/s)",color='black')
plot.title.text = row.name
# plot.title.text_font_size=value("1.0em")
plot.title.text_font="1.0em"
@@ -3466,7 +3472,7 @@ def interactive_windchart(id=0,promember=0):
plot.extra_y_ranges = {"winddirection": Range1d(start=0,end=360)}
plot.line('dist','winddirection',source=source,
legend='Wind Direction',color="red",
legend_label='Wind Direction',color="red",
y_range_name="winddirection")
plot.add_layout(LinearAxis(y_range_name="winddirection",axis_label="Wind Direction (degree)"),'right')
@@ -3526,7 +3532,7 @@ def interactive_streamchart(id=0,promember=0):
# toolbar_location="below",
toolbar_sticky=False,
)
plot.line(dist,vstream,legend="River Stream Velocity (m/s)")
plot.line(dist,vstream,legend_label="River Stream Velocity (m/s)")
plot.title.text = row.name
plot.title.text_font_size=value("1.0em")
plot.xaxis.axis_label = "Distance (m)"
@@ -3607,7 +3613,7 @@ def interactive_chart(id=0,promember=0,intervaldata = {}):
y_range_name = "watermark",
)
plot.line('time','pace',source=source,legend="Pace",name="pace")
plot.line('time','pace',source=source,legend_label="Pace",name="pace")
plot.title.text = row.name
plot.title.text_font_size=value("1.0em")
plot.sizing_mode = 'scale_width'
@@ -3637,7 +3643,7 @@ def interactive_chart(id=0,promember=0,intervaldata = {}):
plot.extra_y_ranges["spmax"] = Range1d(start=10,end=45)
plot.line('time','spm',source=source,color="red",
y_range_name="spmax", legend="Stroke Rate",name="spm")
y_range_name="spmax", legend_label="Stroke Rate",name="spm")
plot.add_layout(LinearAxis(y_range_name="spmax",axis_label="SPM"),'right')
plot.legend.location = "bottom_right"
@@ -3956,7 +3962,7 @@ def interactive_multiflex(datadf,xparam,yparam,groupby,extratitle='',
text = "{gvalue:3.0f}".format(gvalue=gvalue),
background_fill_alpha=1.0,
text_color='black',
text_font_size=value("0.7em"))
text_font_size="0.7em")
plot.add_layout(box)
plot.add_layout(legendlabel)
@@ -3965,7 +3971,7 @@ def interactive_multiflex(datadf,xparam,yparam,groupby,extratitle='',
y_units='screen',
text = 'group legend',
text_color='black',
text_font_size=value("0.7em"),
text_font_size="0.7em",
angle=90,
angle_units='deg')
@@ -4216,7 +4222,7 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
y2label = y1label
plot.circle('x1','y1',source=source2,fill_alpha=0.3,line_color=None,
legend=yparamname1,
legend_label=yparamname1,
)
plot.xaxis.axis_label = axlabels[xparam]
@@ -4240,7 +4246,7 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
plot.extra_y_ranges["yax2"] = yrange2
plot.circle('x1','y2',color="red",y_range_name="yax2",
legend=yparamname2,
legend_label=yparamname2,
source=source2,fill_alpha=0.3,line_color=None)
plot.add_layout(LinearAxis(y_range_name="yax2",
@@ -4361,21 +4367,25 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
""")
slider_spm_min = Slider(start=15.0, end=55,value=15.0, step=.1,
title="Min SPM",callback=callback)
title="Min SPM")
slider_spm_min.js_on_change('value',callback)
callback.args["minspm"] = slider_spm_min
slider_spm_max = Slider(start=15.0, end=55,value=55.0, step=.1,
title="Max SPM",callback=callback)
title="Max SPM")
slider_spm_max.js_on_change('value',callback)
callback.args["maxspm"] = slider_spm_max
slider_work_min = Slider(start=0.0, end=1500,value=0.0, step=10,
title="Min Work per Stroke",callback=callback)
title="Min Work per Stroke")
slider_work_min.js_on_change('value',callback)
callback.args["minwork"] = slider_work_min
slider_work_max = Slider(start=0.0, end=1500,value=1500.0, step=10,
title="Max Work per Stroke",callback=callback)
title="Max Work per Stroke")
slider_work_max.js_on_change('value',callback)
callback.args["maxwork"] = slider_work_max
try:
@@ -4384,12 +4394,14 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
distmax = 1000.
slider_dist_min = Slider(start=0,end=distmax,value=0,step=50,
title="Min Distance",callback=callback)
title="Min Distance")
slider_dist_min.js_on_change('value',callback)
callback.args["mindist"] = slider_dist_min
slider_dist_max = Slider(start=0,end=distmax,value=distmax,
step=50,
title="Max Distance",callback=callback)
title="Max Distance")
slider_dist_max.js_on_change('value',callback)
callback.args["maxdist"] = slider_dist_max
layout = layoutrow([layoutcolumn([slider_spm_min,
@@ -5126,12 +5138,12 @@ def interactive_flex_chart2(id,r,promember=0,
# average values
if yparam1 == 'driveenergy':
if xparam == 'spm':
plot.line(xvals,yconstantpower,color="green",legend="Constant Power")
plot.line(xvals,yconstantpower,color="green",legend_label="Constant Power")
if plottype=='line':
plot.line('x1','y1',source=source2,legend=yaxlabel)
plot.line('x1','y1',source=source2,legend_label=yaxlabel)
elif plottype=='scatter':
plot.scatter('x1','y1',source=source2,legend=yaxlabel,fill_alpha=0.4,
plot.scatter('x1','y1',source=source2,legend_label=yaxlabel,fill_alpha=0.4,
line_color=None)
plot.title.text = row.name
@@ -5200,11 +5212,11 @@ def interactive_flex_chart2(id,r,promember=0,
if plottype=='line':
plot.line('x1','y2',color="red",y_range_name="yax2",
legend=axlegend,
legend_label=axlegend,
source=source2)
elif plottype=='scatter':
plot.scatter('x1','y2',source=source2,legend=axlegend,
plot.scatter('x1','y2',source=source2,legend_label=axlegend,
fill_alpha=0.4,
line_color=None,color="red",y_range_name="yax2")
@@ -5362,26 +5374,30 @@ def interactive_flex_chart2(id,r,promember=0,
source2.change.emit();
""")
annotation = TextInput(title="Type your plot notes here", value="",
callback=callback)
annotation = TextInput(title="Type your plot notes here", value="")
annotation.js_on_change('value',callback)
callback.args["annotation"] = annotation
slider_spm_min = Slider(start=15.0, end=55,value=15.0, step=.1,
title="Min SPM",callback=callback)
title="Min SPM")
slider_spm_min.js_on_change('value',callback)
callback.args["minspm"] = slider_spm_min
slider_spm_max = Slider(start=15.0, end=55,value=55.0, step=.1,
title="Max SPM",callback=callback)
title="Max SPM")
slider_spm_max.js_on_change('value',callback)
callback.args["maxspm"] = slider_spm_max
slider_work_min = Slider(start=0.0, end=1500,value=0.0, step=10,
title="Min Work per Stroke",callback=callback)
title="Min Work per Stroke")
slider_work_min.js_on_change('value',callback)
callback.args["minwork"] = slider_work_min
slider_work_max = Slider(start=0.0, end=1500,value=1500.0, step=10,
title="Max Work per Stroke",callback=callback)
title="Max Work per Stroke")
slider_work_max.js_on_change('value',callback)
callback.args["maxwork"] = slider_work_max
try:
@@ -5390,12 +5406,14 @@ def interactive_flex_chart2(id,r,promember=0,
distmax = 100
slider_dist_min = Slider(start=0,end=distmax,value=0,step=50,
title="Min Distance",callback=callback)
title="Min Distance")
slider_dist_min.js_on_change('value',callback)
callback.args["mindist"] = slider_dist_min
slider_dist_max = Slider(start=0,end=distmax,value=distmax,
step=50,
title="Max Distance",callback=callback)
title="Max Distance")
slider_dist_max.js_on_change('value',callback)
callback.args["maxdist"] = slider_dist_max
thesliders = layoutcolumn([
@@ -5754,27 +5772,27 @@ def interactive_bar_chart(id=0,promember=0):
plot.extra_y_ranges["hr"] = Range1d(start=100,end=200)
plot.quad(left='time',top='hr_ut2',bottom='hr_bottom',
right='x_right',source=source,color="gray",
y_range_name="hr", legend="<UT2")
y_range_name="hr", legend_label="<UT2")
plot.quad(left='time',top='hr_ut1',bottom='hr_bottom',
right='x_right',source=source,color="tan",
y_range_name="hr", legend="UT2")
y_range_name="hr", legend_label="UT2")
plot.quad(left='time',top='hr_at',bottom='hr_bottom',
right='x_right',source=source,color="green",
y_range_name="hr", legend="UT1")
y_range_name="hr", legend_label="UT1")
plot.quad(left='time',top='hr_tr',bottom='hr_bottom',
right='x_right',source=source,color="blue",
y_range_name="hr", legend="AT")
y_range_name="hr", legend_label="AT")
plot.quad(left='time',top='hr_an',bottom='hr_bottom',
right='x_right',source=source,color="violet",
y_range_name="hr", legend="TR")
y_range_name="hr", legend_label="TR")
plot.quad(left='time',top='hr_max',bottom='hr_bottom',
right='x_right',source=source,color="red",
y_range_name="hr", legend="AN")
y_range_name="hr", legend_label="AN")
plot.add_layout(LinearAxis(y_range_name="hr",axis_label="HR"),'right')
plot.line('time','pace',source=source,legend="Pace",color="black")
plot.line('time','pace',source=source,legend_label="Pace",color="black")
script, div = components(plot)
@@ -5993,16 +6011,16 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line',
if labeldict:
try:
legend=labeldict[id]
legend_label=labeldict[id]
except KeyError:
legend = str(id)
else:
legend=str(id)
legend_label=str(id)
if plottype=='line':
l1.append(plot.line('x','y',source=source,color=color,legend=legend,line_width=2))
l1.append(plot.line('x','y',source=source,color=color,legend_label=legend_label,line_width=2))
else:
l1.append(plot.scatter('x','y',source=source,color=color,legend=legend,
l1.append(plot.scatter('x','y',source=source,color=color,legend_label=legend_label,
fill_alpha=0.4,line_color=None))
plot.add_tools(HoverTool(renderers=[l1[cntr]],tooltips=TIPS))
@@ -6229,16 +6247,16 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm',
if plottype=='line':
l1 = plot.line('x1','y1',source=source1,
color="blue",legend=row1.name,
color="blue",legend_label=row1.name,
)
l2 = plot.line('x2','y2',source=source2,
color="red",legend=row2.name,
color="red",legend_label=row2.name,
)
elif plottype=='scatter':
l1 = plot.scatter('x1','y1',source=source1,legend=row1.name,
l1 = plot.scatter('x1','y1',source=source1,legend_label=row1.name,
fill_alpha=0.4,
line_color=None)
l2 = plot.scatter('x2','y2',source=source2,legend=row2.name,
l2 = plot.scatter('x2','y2',source=source2,legend_label=row2.name,
fill_alpha=0.4,
line_color=None,color="red")
@@ -6374,8 +6392,8 @@ def interactive_otw_advanced_pace_chart(id=0,promember=0):
hover = plot.select(dict(type=HoverTool))
plot.line('time','pace',source=source,legend="Pace",color="black")
plot.line('time','nowindpace',source=source,legend="Corrected Pace",color="red")
plot.line('time','pace',source=source,legend_label="Pace",color="black")
plot.line('time','nowindpace',source=source,legend_label="Corrected Pace",color="red")
hover.tooltips = OrderedDict([
('Time','@ftime'),