Private
Public Access
1
0

rough version of comparison

This commit is contained in:
Sander Roosendaal
2017-02-19 16:45:53 +01:00
parent e0b719da4e
commit 0f49402023
8 changed files with 171 additions and 95 deletions

View File

@@ -1582,7 +1582,8 @@ def interactive_bar_chart(id=0,promember=0):
return [script,div]
def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line',
promember=0):
promember=0,
labeldict=None):
columns = [xparam,yparam,
'ftime','distance','fpace',
'power','hr','spm',
@@ -1636,21 +1637,49 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line',
plot = Figure(x_axis_type=x_axis_type,y_axis_type=y_axis_type,
tools=TOOLS,
toolbar_location="above",
plot_width=920,
toolbar_sticky=False)
colors = itertools.cycle(palette)
cntr = 0
for id,color in itertools.izip(ids,colors):
group = datadf[datadf['workoutid']==int(id)].copy()
group.sort_values(by='time',ascending=True,inplace=True)
group['x'] = group[xparam]
group['y'] = group[yparam]
ymean = group['y'].mean()
ylabel = Label(x=100,y=70+20*cntr,
x_units='screen',y_units='screen',
text=yparam+": {ymean:6.2f}".format(ymean=ymean),
background_fill_alpha=.7,
text_color=color,
)
if yparam != 'time' and yparam != 'pace':
plot.add_layout(ylabel)
print cntr,id,len(group),ymean
source = ColumnDataSource(
group
)
plot.line('x','y',source=source,color=color,legend=str(id))
plot.legend.location='top_left'
if labeldict:
legend=labeldict[id]
else:
legend=str(id)
if plottype=='line':
plot.line('x','y',source=source,color=color,legend=legend)
else:
plot.scatter('x','y',source=source,color=color,legend=legend,
fill_alpha=0.4,line_color=None)
cntr += 1
plot.legend.location='bottom_right'
plot.xaxis.axis_label = axlabels[xparam]
plot.yaxis.axis_label = axlabels[yparam]