added title to box plot
This commit is contained in:
@@ -87,11 +87,11 @@ def tailwind(bearing,vwind,winddir):
|
||||
from rowers.dataprep import nicepaceformat,niceformat
|
||||
from rowers.dataprep import timedeltaconv
|
||||
|
||||
def interactive_boxchart(datadf,fieldname):
|
||||
def interactive_boxchart(datadf,fieldname,extratitle=''):
|
||||
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,resize'
|
||||
plot = BoxPlot(datadf, values=fieldname, label='date',
|
||||
legend=False,
|
||||
title=axlabels[fieldname],
|
||||
title=axlabels[fieldname]+' '+extratitle,
|
||||
outliers=False,
|
||||
tools=TOOLS,
|
||||
x_mapper_type='datetime')
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<h1>Box Chart</h1>
|
||||
</div>
|
||||
<div class="grid_4 omega">
|
||||
<form enctype="multipart/form-data" action="/rowers/user-boxplot" method="post">
|
||||
<form enctype="multipart/form-data" action="/rowers/user-boxplot/{{ userid }}" method="post">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
{{ chartform.as_table }}
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<form enctype="multipart/form-data" action="/rowers/user-boxplot" method="post">
|
||||
<form enctype="multipart/form-data" action="/rowers/user-boxplot/{{ theuser.id }}" method="post">
|
||||
<div id="workouts_table" class="grid_8 alpha">
|
||||
|
||||
|
||||
|
||||
@@ -227,6 +227,8 @@ urlpatterns = [
|
||||
url(r'^workout/(?P<id>\d+)/underarmouruploadw/$',views.workout_underarmour_upload_view),
|
||||
url(r'^workout/(?P<id>\d+)/tpuploadw/$',views.workout_tp_upload_view),
|
||||
url(r'^multi-compare$',views.multi_compare_view),
|
||||
url(r'^user-boxplot/(?P<userid>\d+)$',views.boxplot_view),
|
||||
url(r'^user-boxplot/$',views.boxplot_view),
|
||||
url(r'^user-boxplot$',views.boxplot_view),
|
||||
url(r'^me/teams/$',views.rower_teams_view),
|
||||
url(r'^team/(?P<id>\d+)/$',views.team_view),
|
||||
|
||||
@@ -3032,7 +3032,10 @@ def boxplot_view(request,userid=0,
|
||||
|
||||
includereststrokes = options['includereststrokes']
|
||||
workstrokesonly = not includereststrokes
|
||||
|
||||
|
||||
if userid==0:
|
||||
userid = request.user.id
|
||||
|
||||
if request.method == 'POST' and 'workouts' in request.POST:
|
||||
form = WorkoutMultipleCompareForm(request.POST)
|
||||
chartform = BoxPlotChoiceForm(request.POST)
|
||||
@@ -3064,13 +3067,24 @@ def boxplot_view(request,userid=0,
|
||||
datadf['workoutid'].replace(datemapping,inplace=True)
|
||||
datadf.rename(columns={"workoutid":"date"},inplace=True)
|
||||
datadf = datadf.sort_values(['date'])
|
||||
script,div = interactive_boxchart(datadf,plotfield)
|
||||
|
||||
if userid == 0:
|
||||
extratitle = ''
|
||||
else:
|
||||
u = User.objects.get(id=userid)
|
||||
extratitle = ' '+u.first_name+' '+u.last_name
|
||||
|
||||
|
||||
|
||||
script,div = interactive_boxchart(datadf,plotfield,
|
||||
extratitle=extratitle)
|
||||
|
||||
|
||||
return render(request,'boxplot.html',
|
||||
{'interactiveplot':script,
|
||||
'the_div':div,
|
||||
'chartform':chartform,
|
||||
'userid':userid,
|
||||
'teams':get_my_teams(request.user),
|
||||
})
|
||||
else:
|
||||
@@ -3101,13 +3115,22 @@ def boxplot_view(request,userid=0,
|
||||
datadf['workoutid'].replace(datemapping,inplace=True)
|
||||
datadf.rename(columns={"workoutid":"date"},inplace=True)
|
||||
datadf = datadf.sort_values(['date'])
|
||||
script,div = interactive_boxchart(datadf,plotfield)
|
||||
|
||||
if userid == 0:
|
||||
extratitle = ''
|
||||
else:
|
||||
u = User.objects.get(id=userid)
|
||||
extratitle = ' '+u.first_name+' '+u.last_name
|
||||
|
||||
script,div = interactive_boxchart(datadf,plotfield,
|
||||
extratitle=extratitle)
|
||||
|
||||
|
||||
return render(request,'boxplot.html',
|
||||
{'interactiveplot':script,
|
||||
'the_div':div,
|
||||
'chartform':chartform,
|
||||
'userid':userid,
|
||||
'teams':get_my_teams(request.user),
|
||||
})
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user