adding percentages
This commit is contained in:
@@ -6583,7 +6583,8 @@ def interactive_otw_advanced_pace_chart(id=0,promember=0):
|
||||
|
||||
return [script,div]
|
||||
|
||||
def get_zones_report(rower,startdate,enddate,trainingzones='hr',date_agg='week'):
|
||||
def get_zones_report(rower,startdate,enddate,trainingzones='hr',date_agg='week',
|
||||
yaxis='time'):
|
||||
duration = enddate-startdate
|
||||
|
||||
totaldays = duration.total_seconds()/(24*3600)
|
||||
@@ -6594,6 +6595,7 @@ def get_zones_report(rower,startdate,enddate,trainingzones='hr',date_agg='week')
|
||||
hours = []
|
||||
zones = []
|
||||
|
||||
|
||||
workouts = Workout.objects.filter(
|
||||
user=rower,
|
||||
startdatetime__gte=startdate,
|
||||
@@ -6790,7 +6792,8 @@ def get_zones_report(rower,startdate,enddate,trainingzones='hr',date_agg='week')
|
||||
|
||||
return data
|
||||
|
||||
def interactive_zoneschart(rower,data,startdate,enddate,trainingzones='hr',date_agg='week'):
|
||||
def interactive_zoneschart(rower,data,startdate,enddate,trainingzones='hr',date_agg='week',
|
||||
yaxis='time'):
|
||||
duration = enddate-startdate
|
||||
|
||||
totaldays = duration.total_seconds()/(24*3600)
|
||||
@@ -6850,6 +6853,23 @@ def interactive_zoneschart(rower,data,startdate,enddate,trainingzones='hr',date_
|
||||
|
||||
df.sort_values('date_sorting',inplace=True)
|
||||
df.drop('date_sorting',inplace=True,axis='columns')
|
||||
df['totaltime'] = 0
|
||||
|
||||
if yaxis == 'percentage':
|
||||
dates = list(set(df['date'].values))
|
||||
for date in dates:
|
||||
qry = 'date == "{d}"'.format(d=date)
|
||||
|
||||
totaltime = df.query(qry)['hours'].sum()
|
||||
|
||||
mask = df['date'] == date
|
||||
df.loc[mask,'totaltime'] = totaltime
|
||||
|
||||
df['percentage'] = 100.*df['hours']/df['totaltime']
|
||||
df.drop('hours',inplace=True,axis='columns')
|
||||
df.drop('totaltime',inplace=True,axis='columns')
|
||||
print(df.head())
|
||||
|
||||
|
||||
hv.extension('bokeh')
|
||||
|
||||
@@ -6882,6 +6902,9 @@ def interactive_zoneschart(rower,data,startdate,enddate,trainingzones='hr',date_
|
||||
else: # pragma: no cover
|
||||
p.xaxis.axis_label = 'Month'
|
||||
|
||||
if yaxis == 'percentage':
|
||||
p.yaxis.axis_label = 'Percentage'
|
||||
|
||||
p.plot_width=550
|
||||
p.plot_height=350
|
||||
p.toolbar_location = 'above'
|
||||
|
||||
Reference in New Issue
Block a user