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 nicepaceformat,niceformat
|
||||||
from rowers.dataprep import timedeltaconv
|
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'
|
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,resize'
|
||||||
plot = BoxPlot(datadf, values=fieldname, label='date',
|
plot = BoxPlot(datadf, values=fieldname, label='date',
|
||||||
legend=False,
|
legend=False,
|
||||||
title=axlabels[fieldname],
|
title=axlabels[fieldname]+' '+extratitle,
|
||||||
outliers=False,
|
outliers=False,
|
||||||
tools=TOOLS,
|
tools=TOOLS,
|
||||||
x_mapper_type='datetime')
|
x_mapper_type='datetime')
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
<h1>Box Chart</h1>
|
<h1>Box Chart</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_4 omega">
|
<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 %}
|
{% csrf_token %}
|
||||||
<table>
|
<table>
|
||||||
{{ chartform.as_table }}
|
{{ chartform.as_table }}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
</div>
|
</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">
|
<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+)/underarmouruploadw/$',views.workout_underarmour_upload_view),
|
||||||
url(r'^workout/(?P<id>\d+)/tpuploadw/$',views.workout_tp_upload_view),
|
url(r'^workout/(?P<id>\d+)/tpuploadw/$',views.workout_tp_upload_view),
|
||||||
url(r'^multi-compare$',views.multi_compare_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'^user-boxplot$',views.boxplot_view),
|
||||||
url(r'^me/teams/$',views.rower_teams_view),
|
url(r'^me/teams/$',views.rower_teams_view),
|
||||||
url(r'^team/(?P<id>\d+)/$',views.team_view),
|
url(r'^team/(?P<id>\d+)/$',views.team_view),
|
||||||
|
|||||||
@@ -3033,6 +3033,9 @@ def boxplot_view(request,userid=0,
|
|||||||
includereststrokes = options['includereststrokes']
|
includereststrokes = options['includereststrokes']
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
|
|
||||||
|
if userid==0:
|
||||||
|
userid = request.user.id
|
||||||
|
|
||||||
if request.method == 'POST' and 'workouts' in request.POST:
|
if request.method == 'POST' and 'workouts' in request.POST:
|
||||||
form = WorkoutMultipleCompareForm(request.POST)
|
form = WorkoutMultipleCompareForm(request.POST)
|
||||||
chartform = BoxPlotChoiceForm(request.POST)
|
chartform = BoxPlotChoiceForm(request.POST)
|
||||||
@@ -3064,13 +3067,24 @@ def boxplot_view(request,userid=0,
|
|||||||
datadf['workoutid'].replace(datemapping,inplace=True)
|
datadf['workoutid'].replace(datemapping,inplace=True)
|
||||||
datadf.rename(columns={"workoutid":"date"},inplace=True)
|
datadf.rename(columns={"workoutid":"date"},inplace=True)
|
||||||
datadf = datadf.sort_values(['date'])
|
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',
|
return render(request,'boxplot.html',
|
||||||
{'interactiveplot':script,
|
{'interactiveplot':script,
|
||||||
'the_div':div,
|
'the_div':div,
|
||||||
'chartform':chartform,
|
'chartform':chartform,
|
||||||
|
'userid':userid,
|
||||||
'teams':get_my_teams(request.user),
|
'teams':get_my_teams(request.user),
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
@@ -3101,13 +3115,22 @@ def boxplot_view(request,userid=0,
|
|||||||
datadf['workoutid'].replace(datemapping,inplace=True)
|
datadf['workoutid'].replace(datemapping,inplace=True)
|
||||||
datadf.rename(columns={"workoutid":"date"},inplace=True)
|
datadf.rename(columns={"workoutid":"date"},inplace=True)
|
||||||
datadf = datadf.sort_values(['date'])
|
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',
|
return render(request,'boxplot.html',
|
||||||
{'interactiveplot':script,
|
{'interactiveplot':script,
|
||||||
'the_div':div,
|
'the_div':div,
|
||||||
'chartform':chartform,
|
'chartform':chartform,
|
||||||
|
'userid':userid,
|
||||||
'teams':get_my_teams(request.user),
|
'teams':get_my_teams(request.user),
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user