From 4ea452c2cb8c4581a1f0e9090226ff92102880b3 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 4 Mar 2017 20:16:23 +0100 Subject: [PATCH] done comparison chart --- rowers/interactiveplots.py | 14 +- rowers/templates/comparisonchart2.html | 220 ++++++++++++------------- rowers/views.py | 28 ++++ 3 files changed, 141 insertions(+), 121 deletions(-) diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 951c04f8..5e11a871 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -1,4 +1,3 @@ - from rowers.models import Workout, User, Rower, WorkoutForm,RowerForm,GraphImage from rowingdata import rower as rrower from rowingdata import main as rmain @@ -1822,11 +1821,14 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm', else: rowdata2.sort_values(by='time',ascending=True,inplace=True) - x1 = rowdata1.ix[:,xparam] - x2 = rowdata2.ix[:,xparam] + try: + x1 = rowdata1.ix[:,xparam] + x2 = rowdata2.ix[:,xparam] - y1 = rowdata1.ix[:,yparam] - y2 = rowdata2.ix[:,yparam] + y1 = rowdata1.ix[:,yparam] + y2 = rowdata2.ix[:,yparam] + except KeyError: + return "","No valid Data Available" x_axis_type = 'linear' y_axis_type = 'linear' @@ -1949,7 +1951,7 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm', plot.title.text = row1.name+' vs '+row2.name plot.title.text_font_size=value("1.2em") plot.xaxis.axis_label = axlabels[xparam] - + plot.yaxis.axis_label = axlabels[yparam] if xparam == 'time': plot.xaxis[0].formatter = DatetimeTickFormatter( diff --git a/rowers/templates/comparisonchart2.html b/rowers/templates/comparisonchart2.html index c6f664a0..a07b41bd 100644 --- a/rowers/templates/comparisonchart2.html +++ b/rowers/templates/comparisonchart2.html @@ -6,144 +6,134 @@ {% block content %} - - + + - {{ interactiveplot |safe }} +{{ interactiveplot |safe }} - - + +
- - - + + +

 

+
+ - -
- - -
- -
-
- Line Plot -
- -
- +
+ +
+
+ Line Plot +
+ +
+
- {{ the_div|safe }} + {{ the_div|safe }}
diff --git a/rowers/views.py b/rowers/views.py index f61540cb..bbc6514e 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -3253,6 +3253,10 @@ def workout_comparison_view(request,id1=0,id2=0,xparam='distance',yparam='spm'): script = res[0] div = res[1] + axchoicesbasic = {ax[0]:ax[1] for ax in axes if ax[4]=='basic'} + axchoicespro = {ax[0]:ax[1] for ax in axes if ax[4]=='pro'} + noylist = ["time","distance"] + axchoicesbasic.pop("cumdist") return render(request, 'comparisonchart.html', @@ -3260,6 +3264,9 @@ def workout_comparison_view(request,id1=0,id2=0,xparam='distance',yparam='spm'): 'the_div':div, 'id1':id1, 'id2':id2, + 'axchoicesbasic':axchoicesbasic, + 'axchoicespro':axchoicespro, + 'noylist':noylist, 'xparam':xparam, 'yparam':yparam, }) @@ -3283,12 +3290,33 @@ def workout_comparison_view2(request,id1=0,id2=0,xparam='distance', script = res[0] div = res[1] + axchoicesbasic = {ax[0]:ax[1] for ax in axes if ax[4]=='basic'} + axchoicespro = {ax[0]:ax[1] for ax in axes if ax[4]=='pro'} + noylist = ["time","distance"] + axchoicesbasic.pop("cumdist") + + row1 = Workout.objects.get(id=id1) + row2 = Workout.objects.get(id=id2) + + if row1.workouttype != 'water' or row2.workouttype != 'water': + axchoicespro.pop('slip') + axchoicespro.pop('wash') + axchoicespro.pop('catch') + axchoicespro.pop('finish') + axchoicespro.pop('totalangle') + axchoicespro.pop('effectiveangle') + axchoicespro.pop('peakforceangle') + + return render(request, 'comparisonchart2.html', {'interactiveplot':script, 'the_div':div, 'id1':id1, 'id2':id2, + 'axchoicesbasic':axchoicesbasic, + 'axchoicespro':axchoicespro, + 'noylist':noylist, 'xparam':xparam, 'yparam':yparam, 'plottype':plottype,