diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 3e782204..d1e64a9b 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -2344,6 +2344,9 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm', data2 ) + ymean1 = data1['y1'].mean() + ymean2 = data2['y2'].mean() + # create interactive plot plot = Figure(x_axis_type=x_axis_type,y_axis_type=y_axis_type, tools=TOOLS, @@ -2412,6 +2415,25 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm', plot.xaxis.axis_label = axlabels[xparam] plot.yaxis.axis_label = axlabels[yparam] + ylabel1 = Label(x=100,y=90,x_units='screen',y_units='screen', + text=axlabels[yparam]+": {ymean1:6.2f}".format( + ymean1=ymean1 + ), + background_fill_alpha=.7, + background_fill_color='white', + text_color='blue' + ) + ylabel2 = Label(x=100,y=110,x_units='screen',y_units='screen', + text=axlabels[yparam]+": {ymean2:6.2f}".format( + ymean2=ymean2 + ), + background_fill_alpha=.7, + background_fill_color='white', + text_color='red' + ) + plot.add_layout(ylabel1) + plot.add_layout(ylabel2) + if xparam == 'time': plot.xaxis[0].formatter = DatetimeTickFormatter( hours = ["%H"], diff --git a/rowers/templates/analysis.html b/rowers/templates/analysis.html index 9fd83289..04fb8f1c 100644 --- a/rowers/templates/analysis.html +++ b/rowers/templates/analysis.html @@ -83,7 +83,7 @@
-
+

{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %} OTW Ranking Pieces @@ -95,7 +95,17 @@ Analyse power vs piece duration to make predictions.

- +
+

+ {% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %} + Multi Compare + {% else %} + {% endif %} +

+

+ Compare many workouts +

+
diff --git a/rowers/views.py b/rowers/views.py index 9b86f619..c1a8a455 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -3127,6 +3127,8 @@ def team_comparison_select(request, r = getrower(request.user) except Rower.DoesNotExist: raise Http404("Rower doesn't exist") + + if request.method == 'POST': dateform = DateRangeForm(request.POST) @@ -3156,13 +3158,16 @@ def team_comparison_select(request, try: theteam = Team.objects.get(id=teamid) except Team.DoesNotExist: - raise Http404("Team doesn't exist") + theteam = 0 - if theteam.viewing == 'allmembers' or theteam.manager == request.user: + if r.rowerplan == 'basic' and theteam==0: + raise Http404("Not allowed") + + if theteam and (theteam.viewing == 'allmembers' or theteam.manager == request.user): workouts = Workout.objects.filter(team=theteam, startdatetime__gte=startdate, startdatetime__lte=enddate).order_by("-date", "-starttime") - elif theteam.viewing == 'coachonly': + elif theteam and theteam.viewing == 'coachonly': workouts = Workout.objects.filter(team=theteam,user=r, startdatetime__gte=startdate, startdatetime__lte=enddate).order_by("-date","-starttime") @@ -3187,7 +3192,12 @@ def team_comparison_select(request, form = WorkoutMultipleCompareForm() form.fields["workouts"].queryset = workouts - chartform = ChartParamChoiceForm(initial={'teamid':theteam.id}) + if theteam: + theid = theteam.id + else: + theid = 0 + + chartform = ChartParamChoiceForm(initial={'teamid':0}) messages.info(request,successmessage) messages.error(request,message)