added annotations to flex chart
This commit is contained in:
@@ -10,7 +10,7 @@ from django.utils import timezone
|
||||
from bokeh.palettes import Dark2_8 as palette
|
||||
import itertools
|
||||
from bokeh.plotting import figure, ColumnDataSource, Figure,curdoc
|
||||
from bokeh.models import CustomJS,Slider
|
||||
from bokeh.models import CustomJS,Slider, TextInput
|
||||
from bokeh.charts import Histogram,HeatMap
|
||||
from bokeh.resources import CDN,INLINE
|
||||
from bokeh.embed import components
|
||||
@@ -169,46 +169,53 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False):
|
||||
plot.add_layout(avf)
|
||||
|
||||
peakflabel = Label(x=455,y=530,x_units='screen',y_units='screen',
|
||||
text="Fpeak: {peakforceav:6.2f}".format(peakforceav=peakforceav),
|
||||
background_fill_alpha=.7,
|
||||
text_color='blue',
|
||||
text="Fpeak: {peakforceav:6.2f}".format(peakforceav=peakforceav),
|
||||
background_fill_alpha=.7,
|
||||
background_fill_color='white',
|
||||
text_color='blue',
|
||||
)
|
||||
|
||||
avflabel = Label(x=465,y=500,x_units='screen',y_units='screen',
|
||||
text="Favg: {averageforceav:6.2f}".format(averageforceav=averageforceav),
|
||||
background_fill_alpha=.7,
|
||||
background_fill_color='white',
|
||||
text_color='blue',
|
||||
)
|
||||
|
||||
catchlabel = Label(x=460,y=470,x_units='screen',y_units='screen',
|
||||
text="Catch: {catchav:6.2f}".format(catchav=catchav),
|
||||
background_fill_alpha=0.7,
|
||||
background_fill_color='white',
|
||||
text_color='red',
|
||||
)
|
||||
|
||||
peakforceanglelabel = Label(x=420,y=440,x_units='screen',y_units='screen',
|
||||
text="Peak angle: {peakforceangleav:6.2f}".format(peakforceangleav=peakforceangleav),
|
||||
background_fill_alpha=0.7,
|
||||
text_color='red',
|
||||
text="Peak angle: {peakforceangleav:6.2f}".format(peakforceangleav=peakforceangleav),
|
||||
background_fill_alpha=0.7,
|
||||
background_fill_color='white',
|
||||
text_color='red',
|
||||
)
|
||||
|
||||
finishlabel = Label(x=455,y=410,x_units='screen',y_units='screen',
|
||||
text="Finish: {finishav:6.2f}".format(finishav=finishav),
|
||||
background_fill_alpha=0.7,
|
||||
text_color='red',
|
||||
text="Finish: {finishav:6.2f}".format(finishav=finishav),
|
||||
background_fill_alpha=0.7,
|
||||
background_fill_color='white',
|
||||
text_color='red',
|
||||
)
|
||||
|
||||
sliplabel = Label(x=470,y=380,x_units='screen',y_units='screen',
|
||||
text="Slip: {slipav:6.2f}".format(slipav=slipav),
|
||||
background_fill_alpha=0.7,
|
||||
text_color='red',
|
||||
text="Slip: {slipav:6.2f}".format(slipav=slipav),
|
||||
background_fill_alpha=0.7,
|
||||
background_fill_color='white',
|
||||
text_color='red',
|
||||
)
|
||||
|
||||
washlabel = Label(x=460,y=350,x_units='screen',y_units='screen',
|
||||
text="Wash: {washav:6.2f}".format(washav=washav),
|
||||
background_fill_alpha=0.7,
|
||||
text_color='red',
|
||||
)
|
||||
text="Wash: {washav:6.2f}".format(washav=washav),
|
||||
background_fill_alpha=0.7,
|
||||
background_fill_color='white',
|
||||
text_color='red',
|
||||
)
|
||||
|
||||
plot.add_layout(peakflabel)
|
||||
plot.add_layout(peakforceanglelabel)
|
||||
@@ -974,6 +981,7 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
|
||||
xlabel = Label(x=100,y=130,x_units='screen',y_units='screen',
|
||||
text=xparam+": {x1mean:6.2f}".format(x1mean=x1mean),
|
||||
background_fill_alpha=.7,
|
||||
background_fill_color='white',
|
||||
text_color='green',
|
||||
)
|
||||
|
||||
@@ -986,6 +994,7 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
|
||||
y1label = Label(x=100,y=100,x_units='screen',y_units='screen',
|
||||
text=yparam1+": {y1mean:6.2f}".format(y1mean=y1mean),
|
||||
background_fill_alpha=.7,
|
||||
background_fill_color='white',
|
||||
text_color='blue',
|
||||
)
|
||||
|
||||
@@ -1026,6 +1035,7 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
|
||||
y2label = Label(x=100,y=70,x_units='screen',y_units='screen',
|
||||
text=axlabels[yparam2]+": {y2mean:6.2f}".format(y2mean=y2mean),
|
||||
background_fill_alpha=.7,
|
||||
background_fill_color='white',
|
||||
text_color='red',
|
||||
)
|
||||
if yparam2 != 'pace' and yparam2 != 'time':
|
||||
@@ -1309,8 +1319,17 @@ def interactive_flex_chart2(id=0,promember=0,
|
||||
xlabel = Label(x=100,y=130,x_units='screen',y_units='screen',
|
||||
text=axlabels[xparam]+": {x1mean:6.2f}".format(x1mean=x1mean),
|
||||
background_fill_alpha=.7,
|
||||
background_fill_color='white',
|
||||
text_color='green',
|
||||
)
|
||||
)
|
||||
|
||||
annolabel = Label(x=100,y=510,x_units='screen',y_units='screen',
|
||||
text='',
|
||||
background_fill_alpha=0.7,
|
||||
background_fill_color='white',
|
||||
text_color='black',
|
||||
)
|
||||
|
||||
|
||||
if (xparam != 'time') and (xparam != 'distance') and (xparam != 'cumdist'):
|
||||
plot.add_layout(x1means)
|
||||
@@ -1318,10 +1337,12 @@ def interactive_flex_chart2(id=0,promember=0,
|
||||
|
||||
|
||||
plot.add_layout(y1means)
|
||||
plot.add_layout(annolabel)
|
||||
|
||||
y1label = Label(x=100,y=100,x_units='screen',y_units='screen',
|
||||
text=axlabels[yparam1]+": {y1mean:6.2f}".format(y1mean=y1mean),
|
||||
background_fill_alpha=.7,
|
||||
background_fill_color='white',
|
||||
text_color='blue',
|
||||
)
|
||||
if yparam1 != 'time' and yparam1 != 'pace':
|
||||
@@ -1398,6 +1419,7 @@ def interactive_flex_chart2(id=0,promember=0,
|
||||
y2label = Label(x=100,y=70,x_units='screen',y_units='screen',
|
||||
text=axlabels[yparam2]+": {y2mean:6.2f}".format(y2mean=y2mean),
|
||||
background_fill_alpha=.7,
|
||||
background_fill_color='white',
|
||||
text_color='red',
|
||||
)
|
||||
if yparam2 != 'pace' and yparam2 != 'time':
|
||||
@@ -1423,6 +1445,7 @@ def interactive_flex_chart2(id=0,promember=0,
|
||||
y1label=y1label,
|
||||
y2label=y2label,
|
||||
xlabel=xlabel,
|
||||
annolabel=annolabel,
|
||||
y2means=y2means), code="""
|
||||
var data = source.data
|
||||
var data2 = source2.data
|
||||
@@ -1441,6 +1464,7 @@ def interactive_flex_chart2(id=0,promember=0,
|
||||
var yname1 = data['yname1'][0]
|
||||
var yname2 = data['yname2'][0]
|
||||
|
||||
var annotation = annotation.value
|
||||
var minspm = minspm.value
|
||||
var maxspm = maxspm.value
|
||||
var mindist = mindist.value
|
||||
@@ -1504,10 +1528,15 @@ def interactive_flex_chart2(id=0,promember=0,
|
||||
y1label.text = yname1+': '+ym1.toFixed(2)
|
||||
y2label.text = yname2+': '+ym2.toFixed(2)
|
||||
xlabel.text = xname+': '+xm.toFixed(2)
|
||||
annolabel.text = annotation
|
||||
|
||||
source2.trigger('change');
|
||||
""")
|
||||
|
||||
annotation = TextInput(title="Type your plot notes here", value="",
|
||||
callback=callback)
|
||||
callback.args["annotation"] = annotation
|
||||
|
||||
slider_spm_min = Slider(start=15.0, end=55,value=15.0, step=.1,
|
||||
title="Min SPM",callback=callback)
|
||||
callback.args["minspm"] = slider_spm_min
|
||||
@@ -1543,6 +1572,7 @@ def interactive_flex_chart2(id=0,promember=0,
|
||||
slider_dist_max,
|
||||
slider_work_min,
|
||||
slider_work_max,
|
||||
annotation,
|
||||
],
|
||||
),
|
||||
plot])
|
||||
@@ -1738,6 +1768,7 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line',
|
||||
x_units='screen',y_units='screen',
|
||||
text=axlabels[yparam]+": {ymean:6.2f}".format(ymean=ymean),
|
||||
background_fill_alpha=.7,
|
||||
background_fill_color='white',
|
||||
text_color=color,
|
||||
)
|
||||
if yparam != 'time' and yparam != 'pace':
|
||||
|
||||
Reference in New Issue
Block a user