diff --git a/rowers/forms.py b/rowers/forms.py index cf29f328..6f251a2e 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -264,5 +264,11 @@ axlabels = list(axlabels.items()) class ChartParamChoiceForm(forms.Form): + plotchoices = ( + ('line','Line Plot'), + ('scatter','Scatter Plot'), + ) xparam = forms.ChoiceField(choices=axlabels,initial='distance') yparam = forms.ChoiceField(choices=axlabels,initial='hr') + plottype = forms.ChoiceField(choices=plotchoices,initial='scatter') + teamid = forms.IntegerField(widget=forms.HiddenInput()) diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index f71d7e45..6789d0ce 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -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] diff --git a/rowers/stravastuff.py b/rowers/stravastuff.py index b0bf84e4..67780a93 100644 --- a/rowers/stravastuff.py +++ b/rowers/stravastuff.py @@ -39,15 +39,18 @@ from rowsandall_app.settings import C2_CLIENT_ID, C2_REDIRECT_URI, C2_CLIENT_SEC def ewmovingaverage(interval,window_size): # Experimental code using Exponential Weighted moving average - intervaldf = pd.DataFrame({'v':interval}) - idf_ewma1 = intervaldf.ewm(span=window_size) - idf_ewma2 = intervaldf[::-1].ewm(span=window_size) + try: + intervaldf = pd.DataFrame({'v':interval}) + idf_ewma1 = intervaldf.ewm(span=window_size) + idf_ewma2 = intervaldf[::-1].ewm(span=window_size) + + i_ewma1 = idf_ewma1.mean().ix[:,'v'] + i_ewma2 = idf_ewma2.mean().ix[:,'v'] - i_ewma1 = idf_ewma1.mean().ix[:,'v'] - i_ewma2 = idf_ewma2.mean().ix[:,'v'] - - interval2 = np.vstack((i_ewma1,i_ewma2[::-1])) - interval2 = np.mean( interval2, axis=0) # average + interval2 = np.vstack((i_ewma1,i_ewma2[::-1])) + interval2 = np.mean( interval2, axis=0) # average + except ValueError: + interval2 = interval return interval2 diff --git a/rowers/templates/biginteractive1.html b/rowers/templates/biginteractive1.html index 3613da98..97061e31 100644 --- a/rowers/templates/biginteractive1.html +++ b/rowers/templates/biginteractive1.html @@ -6,57 +6,57 @@ {% block content %} - - + + - {{ interactiveplot |safe }} +{{ interactiveplot |safe }} - - + +
- Edit Workout -
-- Advanced Edit -
- -+ Edit Workout +
++ Advanced Edit +
+ +Warning: You are on an experimental part of the site. Use at your own risk.
+Select two or more workouts on the left, set your plot settings below, + and press submit"
{% csrf_token %}+ +
+You can use the date and search forms above to search through all + workouts from this team.
+TIP: Agree with your team members to put tags (e.g. '8x500m') in the notes section of + your workouts. That makes it easy to search.
+