diff --git a/rowers/forms.py b/rowers/forms.py index 37e6c7aa..cf29f328 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -256,3 +256,13 @@ class StatsOptionsForm(forms.Form): class WorkoutMultipleCompareForm(forms.Form): workouts = forms.ModelMultipleChoiceField(queryset=Workout.objects.all(), widget=forms.CheckboxSelectMultiple()) + +from rowers.interactiveplots import axlabels + +axlabels.pop('None') +axlabels = list(axlabels.items()) + + +class ChartParamChoiceForm(forms.Form): + xparam = forms.ChoiceField(choices=axlabels,initial='distance') + yparam = forms.ChoiceField(choices=axlabels,initial='hr') diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index c59b4124..8987651c 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -52,7 +52,7 @@ import rowers.dataprep as dataprep axlabels = { 'time': 'Time', 'distance': 'Distance (m)', - 'cumdist': 'Distance (m)', + 'cumdist': 'Cumulative Distance (m)', 'hr': 'Heart Rate (bpm)', 'spm': 'Stroke Rate (spm)', 'pace': 'Pace (/500m)', @@ -1579,6 +1579,61 @@ def interactive_bar_chart(id=0,promember=0): return [script,div] +def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line'): + columns = [xparam,yparam, + 'ftime','distance','fpace', + 'power','hr','spm', + 'time','pace','workoutstate', + 'workoutid'] + + datadf = dataprep.getsmallrowdata_db(columns,ids=ids) + + yparamname = axlabels[yparam] + + datadf = datadf[datadf[yparam] > 0] + + datadf = datadf[datadf[xparam] > 0] + + # check if dataframe not empty + if datadf.empty: + return ['','
No non-zero data in selection
','',''] + + + + if xparam=='distance': + xaxmax = datadf['distance'].max() + xaxmin = datadf['distance'].min() + else: + xaxmax = yaxmaxima[xparam] + xaxmin = yaxminima[xparam] + + + x_axis_type = 'linear' + y_axis_type = 'linear' + + # Add hover to this comma-separated string and see what changes + if (promember==1): + TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,resize,crosshair' + else: + TOOLS = 'pan,box_zoom,wheel_zoom,reset,tap,crosshair' + + plot = Figure(x_axis_type=x_axis_type,y_axis_type=y_axis_type, + tools=TOOLS, + toolbar_location="above", + toolbar_sticky=False) + + + for key,grp in datadf.groupby(['workoutid']): + print key + + script, div = components(plot) + + + + return [script,div] + + + def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm', promember=0,plottype='line'): diff --git a/rowers/models.py b/rowers/models.py index d43d28c6..b78740e6 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -407,7 +407,7 @@ class Workout(models.Model): ownerlast = self.user.user.last_name duration = self.duration - stri = u'{d}_{n}_{dist}m_{duration:%H:%M:%S}_{ownerfirst}_{ownerlast}'.format( + stri = u'{d} {n} {dist}m {duration:%H:%M:%S} {ownerfirst} {ownerlast}'.format( d = date.strftime('%Y-%m-%d'), n = name, dist = distance, diff --git a/rowers/templates/team_compare_select.html b/rowers/templates/team_compare_select.html index 67988ec9..3908fb47 100644 --- a/rowers/templates/team_compare_select.html +++ b/rowers/templates/team_compare_select.html @@ -51,14 +51,17 @@ -