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)
|
||||
|
||||
metricchoices = (
|
||||
("time","duration"),
|
||||
("TRIMP","trimp"),
|
||||
("rScore","rscore")
|
||||
)
|
||||
|
||||
yaxis = forms.ChoiceField(initial='time',choices=metricchoices,label="Measure by")
|
||||
|
||||
class Meta:
|
||||
fields = ['startdate','enddate']
|
||||
input_formats=("%Y-%m-%d")
|
||||
|
||||
@@ -602,13 +602,17 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
||||
script,div = components(p)
|
||||
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_sorting = []
|
||||
types = []
|
||||
rowers = []
|
||||
durations = []
|
||||
rscores = []
|
||||
trimps = []
|
||||
links = []
|
||||
|
||||
|
||||
@@ -643,6 +647,10 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
|
||||
dd2 = w.date.strftime('%Y/%m/%d')
|
||||
dd3 = w.date.strftime('%Y/%m')
|
||||
du = w.duration.hour*60+w.duration.minute
|
||||
trimp = w.trimp
|
||||
rscore = w.rscore
|
||||
if rscore == 0:
|
||||
rscore = w.hrtss
|
||||
|
||||
if totaldays<30:
|
||||
dates.append(dd)
|
||||
@@ -651,6 +659,8 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
|
||||
dates.append(dd3)
|
||||
dates_sorting.append(dd3)
|
||||
durations.append(du)
|
||||
trimps.append(trimp)
|
||||
rscores.append(rscore)
|
||||
links.append(
|
||||
"{siteurl}/rowers/workout/{code}/".format(
|
||||
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_sorting.append(d.strftime('%Y/%m'))
|
||||
durations.append(0)
|
||||
trimps.append(0)
|
||||
rscores.append(0)
|
||||
links.append('')
|
||||
types.append('rower')
|
||||
|
||||
@@ -705,6 +717,8 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
|
||||
'date':dates,
|
||||
'date_sorting':dates_sorting,
|
||||
'duration':durations,
|
||||
'trimp':trimps,
|
||||
'rscore':rscores,
|
||||
'type':types,
|
||||
'rower':rowers,
|
||||
'link':links,
|
||||
@@ -723,10 +737,12 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
|
||||
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(
|
||||
opts.Bars(color=dim_expr, show_legend=True, stacked=True,
|
||||
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.toolbar_location = toolbar_location
|
||||
p.sizing_mode = 'scale_width'
|
||||
p.y_range.start = 0
|
||||
url = "http://rowsandall.com/rowers/workout/@duration/"
|
||||
taptool = p.select(type=TapTool)
|
||||
|
||||
|
||||
@@ -145,8 +145,8 @@
|
||||
console.log('loading script for chart');
|
||||
var ed = '{{ senddate|date:"Y-m-d" }}'
|
||||
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 }}')
|
||||
$.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) {
|
||||
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 }}&yaxis={{ yaxis }}', function(json) {
|
||||
|
||||
var script = json.script;
|
||||
var div = json.div;
|
||||
|
||||
@@ -4695,12 +4695,15 @@ def history_view(request,userid=0):
|
||||
if request.GET.get('workouttype'):
|
||||
typeselect = request.GET.get('workouttype')
|
||||
|
||||
yaxis = request.GET.get('yaxis','duration')
|
||||
|
||||
if typeselect not in mytypes.checktypes:
|
||||
typeselect = 'All'
|
||||
|
||||
form = HistorySelectForm(initial={'startdate':activity_startdate,
|
||||
'enddate':activity_enddate,
|
||||
'workouttype':typeselect})
|
||||
'workouttype':typeselect,
|
||||
'yaxis':yaxis})
|
||||
|
||||
|
||||
|
||||
@@ -4812,6 +4815,7 @@ def history_view(request,userid=0):
|
||||
'lastyear':lastyear,
|
||||
'today':today,
|
||||
'workouttype':typeselect,
|
||||
'yaxis':yaxis,
|
||||
'firstmay':firstmay,
|
||||
'sstartdate':sstartdate,
|
||||
'senddate':senddate,
|
||||
@@ -4844,6 +4848,7 @@ def history_view_data(request,userid=0):
|
||||
if typeselect not in mytypes.checktypes:
|
||||
typeselect = 'All'
|
||||
|
||||
yaxis = request.GET.get('yaxis','duration')
|
||||
|
||||
g_workouts = Workout.objects.filter(
|
||||
user=r,
|
||||
@@ -4929,7 +4934,7 @@ def history_view_data(request,userid=0):
|
||||
totalsdict['nrworkouts'] = g_workouts.count()
|
||||
|
||||
# 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
|
||||
if typeselect == 'All':
|
||||
|
||||
Reference in New Issue
Block a user