adding TRIMP & rScore option to overview chart in workout list
This commit is contained in:
@@ -421,13 +421,16 @@ def interactive_planchart(data,startdate,enddate):
|
|||||||
|
|
||||||
return script,div
|
return script,div
|
||||||
|
|
||||||
def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_location=None):
|
def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_location=None,
|
||||||
|
yaxis='trimp'):
|
||||||
|
|
||||||
dates = []
|
dates = []
|
||||||
dates_sorting = []
|
dates_sorting = []
|
||||||
types = []
|
types = []
|
||||||
rowers = []
|
rowers = []
|
||||||
durations = []
|
durations = []
|
||||||
|
rscores = []
|
||||||
|
trimps = []
|
||||||
links = []
|
links = []
|
||||||
|
|
||||||
|
|
||||||
@@ -462,6 +465,11 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
|||||||
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
|
||||||
|
rscore = w.rscore
|
||||||
|
trimp = w.trimp
|
||||||
|
|
||||||
|
if rscore == 0:
|
||||||
|
rscore = w.hrtss
|
||||||
|
|
||||||
if totaldays<30:
|
if totaldays<30:
|
||||||
dates.append(dd)
|
dates.append(dd)
|
||||||
@@ -470,6 +478,8 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
|||||||
dates.append(dd3)
|
dates.append(dd3)
|
||||||
dates_sorting.append(dd3)
|
dates_sorting.append(dd3)
|
||||||
durations.append(du)
|
durations.append(du)
|
||||||
|
rscores.append(rscore)
|
||||||
|
trimps.append(trimp)
|
||||||
links.append(
|
links.append(
|
||||||
"{siteurl}/rowers/workout/{code}/".format(
|
"{siteurl}/rowers/workout/{code}/".format(
|
||||||
siteurl = settings.SITE_URL,
|
siteurl = settings.SITE_URL,
|
||||||
@@ -506,6 +516,8 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
|||||||
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)
|
||||||
|
rscores.append(0)
|
||||||
|
trimps.append(0)
|
||||||
links.append('')
|
links.append('')
|
||||||
types.append('rower')
|
types.append('rower')
|
||||||
|
|
||||||
@@ -524,6 +536,8 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
|||||||
'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,
|
||||||
@@ -541,13 +555,15 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
|||||||
hv.extension('bokeh')
|
hv.extension('bokeh')
|
||||||
|
|
||||||
if stack == 'type':
|
if stack == 'type':
|
||||||
table = hv.Table(df,[('date','Date'),('type','Workout Type')],[('duration','Minutes'),('link','link')])
|
table = hv.Table(df,[('date','Date'),('type','Workout Type')],
|
||||||
|
[('duration','Minutes'),('rscore','rScore'),('trimp','TRIMP'),('link','link')])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
table = hv.Table(df,[('date','Date'),('rower','Rower')],[('duration','Minutes'),('link','link')])
|
table = hv.Table(df,[('date','Date'),('rower','Rower')],
|
||||||
|
[('duration','Minutes'),('rscore','rScore'),('trimp','TRIMP'),('link','link')])
|
||||||
|
|
||||||
|
|
||||||
bars=table.to.bars(['date',stack],['duration'])
|
bars=table.to.bars(['date',stack],[yaxis])
|
||||||
bars.opts(
|
bars.opts(
|
||||||
opts.Bars(color=hv.Cycle('Category10'), show_legend=True, stacked=True,
|
opts.Bars(color=hv.Cycle('Category10'), 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)),
|
||||||
|
|||||||
@@ -63,6 +63,12 @@
|
|||||||
Total meters: {{ totalmeters }}. Total time {{ totalhours }}:{{ totalminutes }}h.
|
Total meters: {{ totalmeters }}. Total time {{ totalhours }}:{{ totalminutes }}h.
|
||||||
<a href="/rowers/history/">Dig deeper</a>.
|
<a href="/rowers/history/">Dig deeper</a>.
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
Activity chart by
|
||||||
|
<a href="{{ request.get_path }}?yaxis=trimp">TRIMP</a>,
|
||||||
|
<a href="{{ request.get_path }}?yaxis=rscore">rScore</a>,
|
||||||
|
<a href="{{ request.get_path }}?yaxis=duration">Time</a>.
|
||||||
|
</p>
|
||||||
<link rel="stylesheet" href="https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.css" type="text/css" />
|
<link rel="stylesheet" href="https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css" type="text/css" />
|
<link rel="stylesheet" href="https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css" type="text/css" />
|
||||||
<script src="https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js"></script>
|
<script src="https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js"></script>
|
||||||
|
|||||||
@@ -2134,11 +2134,15 @@ def workouts_view(request,message='',successmessage='',
|
|||||||
else:
|
else:
|
||||||
stack='type'
|
stack='type'
|
||||||
|
|
||||||
|
yaxis = request.GET.get('yaxis','duration')
|
||||||
|
if yaxis not in ['duration','trimp','rscore']:
|
||||||
|
yaxis = 'duration'
|
||||||
|
|
||||||
script,div = interactive_activitychart(g_workouts,
|
script,div = interactive_activitychart(g_workouts,
|
||||||
g_startdate,
|
g_startdate,
|
||||||
g_enddate,
|
g_enddate,
|
||||||
stack=stack)
|
stack=stack,
|
||||||
|
yaxis=yaxis)
|
||||||
|
|
||||||
totalmeters,totalhours, totalminutes,total_seconds = get_totals(g_workouts)
|
totalmeters,totalhours, totalminutes,total_seconds = get_totals(g_workouts)
|
||||||
totalminutes = '{totalminutes:02d}'.format(totalminutes=totalminutes)
|
totalminutes = '{totalminutes:02d}'.format(totalminutes=totalminutes)
|
||||||
|
|||||||
Reference in New Issue
Block a user