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
|
||||
|
||||
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_sorting = []
|
||||
types = []
|
||||
rowers = []
|
||||
durations = []
|
||||
rscores = []
|
||||
trimps = []
|
||||
links = []
|
||||
|
||||
|
||||
@@ -462,6 +465,11 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
||||
dd2 = w.date.strftime('%Y/%m/%d')
|
||||
dd3 = w.date.strftime('%Y/%m')
|
||||
du = w.duration.hour*60+w.duration.minute
|
||||
rscore = w.rscore
|
||||
trimp = w.trimp
|
||||
|
||||
if rscore == 0:
|
||||
rscore = w.hrtss
|
||||
|
||||
if totaldays<30:
|
||||
dates.append(dd)
|
||||
@@ -470,6 +478,8 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
||||
dates.append(dd3)
|
||||
dates_sorting.append(dd3)
|
||||
durations.append(du)
|
||||
rscores.append(rscore)
|
||||
trimps.append(trimp)
|
||||
links.append(
|
||||
"{siteurl}/rowers/workout/{code}/".format(
|
||||
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_sorting.append(d.strftime('%Y/%m'))
|
||||
durations.append(0)
|
||||
rscores.append(0)
|
||||
trimps.append(0)
|
||||
links.append('')
|
||||
types.append('rower')
|
||||
|
||||
@@ -524,6 +536,8 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
||||
'date':dates,
|
||||
'date_sorting':dates_sorting,
|
||||
'duration':durations,
|
||||
'trimp':trimps,
|
||||
'rscore':rscores,
|
||||
'type':types,
|
||||
'rower':rowers,
|
||||
'link':links,
|
||||
@@ -541,13 +555,15 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
||||
hv.extension('bokeh')
|
||||
|
||||
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:
|
||||
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(
|
||||
opts.Bars(color=hv.Cycle('Category10'), show_legend=True, stacked=True,
|
||||
tools=['tap','hover'], width=550, xrotation=45,padding=(0,(0,.1)),
|
||||
|
||||
@@ -63,6 +63,12 @@
|
||||
Total meters: {{ totalmeters }}. Total time {{ totalhours }}:{{ totalminutes }}h.
|
||||
<a href="/rowers/history/">Dig deeper</a>.
|
||||
</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-widgets-1.0.4.min.css" type="text/css" />
|
||||
<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:
|
||||
stack='type'
|
||||
|
||||
yaxis = request.GET.get('yaxis','duration')
|
||||
if yaxis not in ['duration','trimp','rscore']:
|
||||
yaxis = 'duration'
|
||||
|
||||
script,div = interactive_activitychart(g_workouts,
|
||||
g_startdate,
|
||||
g_enddate,
|
||||
stack=stack)
|
||||
stack=stack,
|
||||
yaxis=yaxis)
|
||||
|
||||
totalmeters,totalhours, totalminutes,total_seconds = get_totals(g_workouts)
|
||||
totalminutes = '{totalminutes:02d}'.format(totalminutes=totalminutes)
|
||||
|
||||
Reference in New Issue
Block a user