From d8a4ddf9768d4964348512b15bfc9904547a31a0 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Fri, 7 Jul 2017 09:51:51 +0200 Subject: [PATCH 1/2] some small improvements on multiflex --- rowers/.#interactiveplots.py | 1 + rowers/views.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 rowers/.#interactiveplots.py diff --git a/rowers/.#interactiveplots.py b/rowers/.#interactiveplots.py new file mode 100644 index 00000000..ff7b995a --- /dev/null +++ b/rowers/.#interactiveplots.py @@ -0,0 +1 @@ +E408191@CZ27LT9RCGN72.21108:1499200053 \ No newline at end of file diff --git a/rowers/views.py b/rowers/views.py index 0b17d389..6c229c00 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -3458,6 +3458,8 @@ def multiflex_view(request,userid=0, binsize = chartform.cleaned_data['binsize'] if binsize <= 0: binsize = 1 + if groupby == 'pace': + binsize *= 1000 spmmin = chartform.cleaned_data['spmmin'] spmmax = chartform.cleaned_data['spmmax'] @@ -3573,6 +3575,8 @@ def multiflex_view(request,userid=0, binsize = chartform.cleaned_data['binsize'] if binsize <= 0: binsize = 1 + if groupby == 'pace': + binsize *= 1000. spmmin = chartform.cleaned_data['spmmin'] spmmax = chartform.cleaned_data['spmmax'] @@ -3658,7 +3662,10 @@ def multiflex_view(request,userid=0, 'yerror':yerror, }) - if groupby != 'date': + + if groupby == 'pace': + df['groupval'] = groups.mean()[groupby].fillna(value=0)/1000. + elif groupby != 'date': try: df['groupval'] = groups.mean()[groupby], except ValueError: From 37118e896cd8dcd7659b8552472d92fe202a730c Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Fri, 7 Jul 2017 16:39:08 +0200 Subject: [PATCH 2/2] plot title in trend flex --- rowers/.#interactiveplots.py | 1 - rowers/forms.py | 1 + rowers/interactiveplots.py | 63 ++++++++++++++++++++++++++++++++---- 3 files changed, 57 insertions(+), 8 deletions(-) delete mode 100644 rowers/.#interactiveplots.py diff --git a/rowers/.#interactiveplots.py b/rowers/.#interactiveplots.py deleted file mode 100644 index ff7b995a..00000000 --- a/rowers/.#interactiveplots.py +++ /dev/null @@ -1 +0,0 @@ -E408191@CZ27LT9RCGN72.21108:1499200053 \ No newline at end of file diff --git a/rowers/forms.py b/rowers/forms.py index 1ec60254..95ee6b02 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -324,6 +324,7 @@ groupchoices = list(sorted(grouplabels.items(), key = lambda x:x[1])) formaxlabelsmultiflex = formaxlabels.copy() formaxlabelsmultiflex.pop('time') formaxlabelsmultiflex.pop('distance') +formaxlabelsmultiflex['workoutid'] = 'Workout' parchoicesmultiflex = list(sorted(formaxlabelsmultiflex.items(), key = lambda x:x[1])) diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index a22d525c..6bbf023a 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -1164,14 +1164,34 @@ def interactive_chart(id=0,promember=0): return [script,div] def interactive_multiflex(datadf,xparam,yparam,groupby,extratitle='', - ploterrorbars=False): + ploterrorbars=False, + title=None): if datadf.empty: return ['','

No non-zero data in selection

'] + if xparam == 'workoutid': + xparamname = 'Workout' + else: + xparamname = axlabels[xparam] - xparamname = axlabels[xparam] - yparamname = axlabels[yparam] + if yparam == 'workoutid': + yparamname = 'Workout' + else: + yparamname = axlabels[yparam] + + if groupby == 'workoutid': + groupname = 'Workout' + else: + groupname = axlabels[groupby] + + + if title==None: + title = '{y} vs {x} grouped by {gr}'.format( + x = xparamname, + y = yparamname, + gr = groupname, + ) if xparam=='distance': @@ -1181,10 +1201,27 @@ def interactive_multiflex(datadf,xparam,yparam,groupby,extratitle='', tseconds = datadf.ix[:,'time'] xaxmax = tseconds.max() xaxmin = 0 + elif xparam == 'workoutid': + xaxmax = datadf[xparam].max()-5 + xaxmin = datadf[xparam].min()+5 else: xaxmax = yaxmaxima[xparam] xaxmin = yaxminima[xparam] + if yparam=='distance': + yaxmax = datadf[yparam].max() + yaxmin = datadf[yparam].min() + elif yparam=='time': + tseconds = datadf.ix[:,'time'] + yaxmax = tseconds.max() + yaxmin = 0 + elif yparam == 'workoutid': + yaxmax = datadf[yparam].max()-5 + yaxmin = datadf[yparam].min()+5 + else: + yaxmax = yaxmaxima[yparam] + yaxmin = yaxminima[yparam] + x_axis_type = 'linear' y_axis_type = 'linear' if xparam == 'time': @@ -1207,6 +1244,9 @@ def interactive_multiflex(datadf,xparam,yparam,groupby,extratitle='', plot.extra_y_ranges = {"watermark": watermarkrange} plot.extra_x_ranges = {"watermark": watermarkrange} + plot.title.text = title + plot.title.text_font_size=value("1.0em") + plot.image_url([watermarkurl],watermarkx,watermarky, watermarkw,watermarkh, global_alpha=watermarkalpha, @@ -1227,14 +1267,21 @@ def interactive_multiflex(datadf,xparam,yparam,groupby,extratitle='', 'size':10, }) - plot.xaxis.axis_label = axlabels[xparam] - plot.yaxis.axis_label = axlabels[yparam] + if xparam == 'workoutid': + plot.xaxis.axis_label = 'Workout' + else: + plot.xaxis.axis_label = axlabels[xparam] + + if yparam == 'workoutid': + plot.xaxis.axis_label = 'Workout' + else: + plot.yaxis.axis_label = axlabels[yparam] - yrange1 = Range1d(start=yaxminima[yparam],end=yaxmaxima[yparam]) + yrange1 = Range1d(start=yaxmin,end=yaxmax) plot.y_range = yrange1 - xrange1 = Range1d(start=yaxminima[xparam],end=yaxmaxima[xparam]) + xrange1 = Range1d(start=xaxmin,end=xaxmax) plot.x_range = xrange1 if yparam == 'pace': @@ -1245,6 +1292,8 @@ def interactive_multiflex(datadf,xparam,yparam,groupby,extratitle='', hover = plot.select(dict(type=HoverTool)) + + if groupby != 'date': hover.tooltips = OrderedDict([ (groupby,'@groupval{1.1}'),