activity chart on history page can be switched to rscore or trimp
This commit is contained in:
@@ -161,6 +161,14 @@ class HistorySelectForm(forms.Form):
|
|||||||
|
|
||||||
workouttype = forms.ChoiceField(initial='All',choices=typeselectchoices)
|
workouttype = forms.ChoiceField(initial='All',choices=typeselectchoices)
|
||||||
|
|
||||||
|
metricchoices = (
|
||||||
|
("time","duration"),
|
||||||
|
("TRIMP","trimp"),
|
||||||
|
("rScore","rscore")
|
||||||
|
)
|
||||||
|
|
||||||
|
yaxis = forms.ChoiceField(initial='time',choices=metricchoices,label="Measure by")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
fields = ['startdate','enddate']
|
fields = ['startdate','enddate']
|
||||||
input_formats=("%Y-%m-%d")
|
input_formats=("%Y-%m-%d")
|
||||||
|
|||||||
@@ -602,13 +602,17 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
|||||||
script,div = components(p)
|
script,div = components(p)
|
||||||
return script,div
|
return script,div
|
||||||
|
|
||||||
def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_location=None):
|
def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_location=None,
|
||||||
|
yaxis='duration'):
|
||||||
|
|
||||||
|
|
||||||
dates = []
|
dates = []
|
||||||
dates_sorting = []
|
dates_sorting = []
|
||||||
types = []
|
types = []
|
||||||
rowers = []
|
rowers = []
|
||||||
durations = []
|
durations = []
|
||||||
|
rscores = []
|
||||||
|
trimps = []
|
||||||
links = []
|
links = []
|
||||||
|
|
||||||
|
|
||||||
@@ -643,6 +647,10 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
|
|||||||
dd2 = w.date.strftime('%Y/%m/%d')
|
dd2 = w.date.strftime('%Y/%m/%d')
|
||||||
dd3 = w.date.strftime('%Y/%m')
|
dd3 = w.date.strftime('%Y/%m')
|
||||||
du = w.duration.hour*60+w.duration.minute
|
du = w.duration.hour*60+w.duration.minute
|
||||||
|
trimp = w.trimp
|
||||||
|
rscore = w.rscore
|
||||||
|
if rscore == 0:
|
||||||
|
rscore = w.hrtss
|
||||||
|
|
||||||
if totaldays<30:
|
if totaldays<30:
|
||||||
dates.append(dd)
|
dates.append(dd)
|
||||||
@@ -651,6 +659,8 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
|
|||||||
dates.append(dd3)
|
dates.append(dd3)
|
||||||
dates_sorting.append(dd3)
|
dates_sorting.append(dd3)
|
||||||
durations.append(du)
|
durations.append(du)
|
||||||
|
trimps.append(trimp)
|
||||||
|
rscores.append(rscore)
|
||||||
links.append(
|
links.append(
|
||||||
"{siteurl}/rowers/workout/{code}/".format(
|
"{siteurl}/rowers/workout/{code}/".format(
|
||||||
siteurl = settings.SITE_URL,
|
siteurl = settings.SITE_URL,
|
||||||
@@ -687,6 +697,8 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
|
|||||||
dates.append(d.strftime('%Y/%m'))
|
dates.append(d.strftime('%Y/%m'))
|
||||||
dates_sorting.append(d.strftime('%Y/%m'))
|
dates_sorting.append(d.strftime('%Y/%m'))
|
||||||
durations.append(0)
|
durations.append(0)
|
||||||
|
trimps.append(0)
|
||||||
|
rscores.append(0)
|
||||||
links.append('')
|
links.append('')
|
||||||
types.append('rower')
|
types.append('rower')
|
||||||
|
|
||||||
@@ -705,6 +717,8 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
|
|||||||
'date':dates,
|
'date':dates,
|
||||||
'date_sorting':dates_sorting,
|
'date_sorting':dates_sorting,
|
||||||
'duration':durations,
|
'duration':durations,
|
||||||
|
'trimp':trimps,
|
||||||
|
'rscore':rscores,
|
||||||
'type':types,
|
'type':types,
|
||||||
'rower':rowers,
|
'rower':rowers,
|
||||||
'link':links,
|
'link':links,
|
||||||
@@ -723,10 +737,12 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
|
|||||||
hv.extension('bokeh')
|
hv.extension('bokeh')
|
||||||
|
|
||||||
|
|
||||||
table = hv.Table(df,[('date','Date'),('type','Workout Type')],[('duration','Minutes'),('link','link')])
|
table = hv.Table(df,[('date','Date'),('type','Workout Type')],
|
||||||
|
[('duration','Minutes'),('trimp','TRIMP'),('rscore','rScore'),('link','link')])
|
||||||
|
|
||||||
|
|
||||||
bars=table.to.bars(['date',stack],['duration'])
|
bars=table.to.bars(['date',stack],[yaxis])
|
||||||
|
|
||||||
bars.opts(
|
bars.opts(
|
||||||
opts.Bars(color=dim_expr, show_legend=True, stacked=True,
|
opts.Bars(color=dim_expr, show_legend=True, stacked=True,
|
||||||
tools=['tap','hover'], width=550, xrotation=45,padding=(0,(0,.1)),
|
tools=['tap','hover'], width=550, xrotation=45,padding=(0,(0,.1)),
|
||||||
@@ -745,6 +761,7 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
|
|||||||
p.plot_height=350
|
p.plot_height=350
|
||||||
p.toolbar_location = toolbar_location
|
p.toolbar_location = toolbar_location
|
||||||
p.sizing_mode = 'scale_width'
|
p.sizing_mode = 'scale_width'
|
||||||
|
p.y_range.start = 0
|
||||||
url = "http://rowsandall.com/rowers/workout/@duration/"
|
url = "http://rowsandall.com/rowers/workout/@duration/"
|
||||||
taptool = p.select(type=TapTool)
|
taptool = p.select(type=TapTool)
|
||||||
|
|
||||||
|
|||||||
@@ -145,8 +145,8 @@
|
|||||||
console.log('loading script for chart');
|
console.log('loading script for chart');
|
||||||
var ed = '{{ senddate|date:"Y-m-d" }}'
|
var ed = '{{ senddate|date:"Y-m-d" }}'
|
||||||
console.log('End',ed);
|
console.log('End',ed);
|
||||||
console.log(window.location.protocol + '//'+window.location.host + '/rowers/history/user/{{ rower.user.id }}/data/?startdate={{ sstartdate|date:"Y-m-d" }}&enddate={{ senddate|date:"Y-m-d" }}&workouttype={{ workouttype }}')
|
console.log(window.location.protocol + '//'+window.location.host + '/rowers/history/user/{{ rower.user.id }}/data/?startdate={{ sstartdate|date:"Y-m-d" }}&enddate={{ senddate|date:"Y-m-d" }}&workouttype={{ workouttype }}&yaxis={{ yaxis }}')
|
||||||
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/history/user/{{ rower.user.id }}/data/?startdate={{ sstartdate|date:"Y-m-d" }}&enddate={{ senddate|date:"Y-m-d" }}&workouttype={{ workouttype }}', function(json) {
|
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/history/user/{{ rower.user.id }}/data/?startdate={{ sstartdate|date:"Y-m-d" }}&enddate={{ senddate|date:"Y-m-d" }}&workouttype={{ workouttype }}&yaxis={{ yaxis }}', function(json) {
|
||||||
|
|
||||||
var script = json.script;
|
var script = json.script;
|
||||||
var div = json.div;
|
var div = json.div;
|
||||||
|
|||||||
@@ -4695,12 +4695,15 @@ def history_view(request,userid=0):
|
|||||||
if request.GET.get('workouttype'):
|
if request.GET.get('workouttype'):
|
||||||
typeselect = request.GET.get('workouttype')
|
typeselect = request.GET.get('workouttype')
|
||||||
|
|
||||||
|
yaxis = request.GET.get('yaxis','duration')
|
||||||
|
|
||||||
if typeselect not in mytypes.checktypes:
|
if typeselect not in mytypes.checktypes:
|
||||||
typeselect = 'All'
|
typeselect = 'All'
|
||||||
|
|
||||||
form = HistorySelectForm(initial={'startdate':activity_startdate,
|
form = HistorySelectForm(initial={'startdate':activity_startdate,
|
||||||
'enddate':activity_enddate,
|
'enddate':activity_enddate,
|
||||||
'workouttype':typeselect})
|
'workouttype':typeselect,
|
||||||
|
'yaxis':yaxis})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -4812,6 +4815,7 @@ def history_view(request,userid=0):
|
|||||||
'lastyear':lastyear,
|
'lastyear':lastyear,
|
||||||
'today':today,
|
'today':today,
|
||||||
'workouttype':typeselect,
|
'workouttype':typeselect,
|
||||||
|
'yaxis':yaxis,
|
||||||
'firstmay':firstmay,
|
'firstmay':firstmay,
|
||||||
'sstartdate':sstartdate,
|
'sstartdate':sstartdate,
|
||||||
'senddate':senddate,
|
'senddate':senddate,
|
||||||
@@ -4844,6 +4848,7 @@ def history_view_data(request,userid=0):
|
|||||||
if typeselect not in mytypes.checktypes:
|
if typeselect not in mytypes.checktypes:
|
||||||
typeselect = 'All'
|
typeselect = 'All'
|
||||||
|
|
||||||
|
yaxis = request.GET.get('yaxis','duration')
|
||||||
|
|
||||||
g_workouts = Workout.objects.filter(
|
g_workouts = Workout.objects.filter(
|
||||||
user=r,
|
user=r,
|
||||||
@@ -4929,7 +4934,7 @@ def history_view_data(request,userid=0):
|
|||||||
totalsdict['nrworkouts'] = g_workouts.count()
|
totalsdict['nrworkouts'] = g_workouts.count()
|
||||||
|
|
||||||
# activity chart
|
# activity chart
|
||||||
activity_script, activity_div = interactive_activitychart2(g_workouts,startdate,enddate)
|
activity_script, activity_div = interactive_activitychart2(g_workouts,startdate,enddate,yaxis=yaxis)
|
||||||
|
|
||||||
# interactive hr pie chart
|
# interactive hr pie chart
|
||||||
if typeselect == 'All':
|
if typeselect == 'All':
|
||||||
|
|||||||
Reference in New Issue
Block a user