fix #459
This commit is contained in:
@@ -1214,12 +1214,13 @@ def fitnessmetric_chart(fitnessmetrics,user,workoutmode='rower',startdate=None,
|
||||
|
||||
return [script,div]
|
||||
|
||||
def interactive_histoall(theworkouts):
|
||||
def interactive_histoall(theworkouts,histoparam,includereststrokes):
|
||||
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
|
||||
|
||||
ids = [int(w.id) for w in theworkouts]
|
||||
|
||||
rowdata = dataprep.getsmallrowdata_db(['power'],ids=ids,doclean=True)
|
||||
workstrokesonly = not includereststrokes
|
||||
rowdata = dataprep.getsmallrowdata_db([histoparam],ids=ids,doclean=True,workstrokesonly=workstrokesonly)
|
||||
|
||||
rowdata.dropna(axis=0,how='any',inplace=True)
|
||||
|
||||
@@ -1227,16 +1228,16 @@ def interactive_histoall(theworkouts):
|
||||
return "","No Valid Data Available","",""
|
||||
|
||||
try:
|
||||
histopwr = rowdata['power'].values
|
||||
histopwr = rowdata[histoparam].values
|
||||
except KeyError:
|
||||
return "","No power data","",""
|
||||
return "","No data","",""
|
||||
if len(histopwr) == 0:
|
||||
return "","No valid data available","",""
|
||||
|
||||
# throw out nans
|
||||
histopwr = histopwr[~np.isinf(histopwr)]
|
||||
histopwr = histopwr[histopwr > 25]
|
||||
histopwr = histopwr[histopwr < 1000]
|
||||
histopwr = histopwr[histopwr > yaxminima[histoparam]]
|
||||
histopwr = histopwr[histopwr < yaxmaxima[histoparam]]
|
||||
|
||||
plot = Figure(tools=TOOLS,plot_width=900,
|
||||
toolbar_sticky=False,
|
||||
@@ -1289,7 +1290,7 @@ def interactive_histoall(theworkouts):
|
||||
# plot.quad(top='hist_norm',bottom=0,left=edges[:-1],right=edges[1:])
|
||||
plot.quad(top='hist_norm',bottom=0,left='left',right='right',source=source)
|
||||
|
||||
plot.xaxis.axis_label = "Power (W)"
|
||||
plot.xaxis.axis_label = axlabels[histoparam]
|
||||
plot.yaxis.axis_label = "% of strokes"
|
||||
plot.y_range = Range1d(0,1.05*max(hist_norm))
|
||||
|
||||
@@ -1297,7 +1298,7 @@ def interactive_histoall(theworkouts):
|
||||
hover = plot.select(dict(type=HoverTool))
|
||||
|
||||
hover.tooltips = OrderedDict([
|
||||
('Power(W)','@left{int}'),
|
||||
(axlabels[histoparam],'@left{int}'),
|
||||
('% of strokes','@hist_norm'),
|
||||
('Cumulative %','@histsum{int}'),
|
||||
])
|
||||
@@ -1311,12 +1312,36 @@ def interactive_histoall(theworkouts):
|
||||
axis_label="Cumulative % of strokes"),'right')
|
||||
|
||||
plot.sizing_mode = 'scale_width'
|
||||
|
||||
annolabel = Label(x=50,y=450,x_units='screen',y_units='screen',
|
||||
text='',
|
||||
background_fill_alpha=0.7,
|
||||
background_fill_color='white',
|
||||
text_color='black',
|
||||
)
|
||||
|
||||
plot.add_layout(annolabel)
|
||||
|
||||
callback = CustomJS(args = dict(
|
||||
annolabel=annolabel,
|
||||
), code="""
|
||||
var annotation = annotation.value
|
||||
annolabel.text = annotation
|
||||
""")
|
||||
|
||||
annotation = TextInput(title="Type your plot notes here", value="",
|
||||
callback=callback)
|
||||
callback.args["annotation"] = annotation
|
||||
|
||||
layout = layoutcolumn([annotation,plot])
|
||||
|
||||
try:
|
||||
script, div = components(plot)
|
||||
script, div = components(layout)
|
||||
except ValueError:
|
||||
script = ''
|
||||
div = ''
|
||||
|
||||
|
||||
|
||||
return [script,div]
|
||||
|
||||
def course_map(course):
|
||||
@@ -3889,7 +3914,7 @@ def interactive_flex_chart2(id=0,promember=0,
|
||||
""")
|
||||
|
||||
annotation = TextInput(title="Type your plot notes here", value="",
|
||||
callback=callback)
|
||||
callback=callback)
|
||||
callback.args["annotation"] = annotation
|
||||
|
||||
slider_spm_min = Slider(start=15.0, end=55,value=15.0, step=.1,
|
||||
|
||||
Reference in New Issue
Block a user