Private
Public Access
1
0

bar charts on team list by rower, not by type

This commit is contained in:
Sander Roosendaal
2017-10-17 09:39:30 +02:00
parent 353aeb5ab3
commit 63f1895343
2 changed files with 14 additions and 5 deletions

View File

@@ -219,12 +219,13 @@ def interactive_boxchart(datadf,fieldname,extratitle=''):
return script,div
def interactive_activitychart(workouts,startdate,enddate):
def interactive_activitychart(workouts,startdate,enddate,stack='type'):
if len(workouts) == 0:
return "",""
dates = []
types = []
rowers = []
durations = []
for w in workouts:
@@ -234,6 +235,7 @@ def interactive_activitychart(workouts,startdate,enddate):
dates.append(dd)
durations.append(du)
types.append(w.workouttype)
rowers.append(w.user.user.first_name)
try:
d = utc.localize(startdate)
@@ -250,17 +252,18 @@ def interactive_activitychart(workouts,startdate,enddate):
dates.append(d.strftime('%m/%d'))
durations.append(0)
types.append('rower')
rowers.append('Sander')
d += datetime.timedelta(days=1)
df = pd.DataFrame({
'date':dates,
'duration':durations,
'type':types,
'rower':rowers,
})
p = Bar(df,'date',values='duration',title='Activity',
stack='type',
stack=stack,
plot_width=350,
plot_height=250,
toolbar_location = None,
@@ -270,7 +273,7 @@ def interactive_activitychart(workouts,startdate,enddate):
new_items = []
for legend_item in legend.items:
it = legend_item.label['value']
tot = df[df['type']==it].duration.sum()
tot = df[df[stack]==it].duration.sum()
if tot != 0:
new_items.append(legend_item)
legend.items = new_items