bar charts on team list by rower, not by type
This commit is contained in:
@@ -219,12 +219,13 @@ def interactive_boxchart(datadf,fieldname,extratitle=''):
|
|||||||
return script,div
|
return script,div
|
||||||
|
|
||||||
|
|
||||||
def interactive_activitychart(workouts,startdate,enddate):
|
def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
||||||
if len(workouts) == 0:
|
if len(workouts) == 0:
|
||||||
return "",""
|
return "",""
|
||||||
|
|
||||||
dates = []
|
dates = []
|
||||||
types = []
|
types = []
|
||||||
|
rowers = []
|
||||||
durations = []
|
durations = []
|
||||||
|
|
||||||
for w in workouts:
|
for w in workouts:
|
||||||
@@ -234,6 +235,7 @@ def interactive_activitychart(workouts,startdate,enddate):
|
|||||||
dates.append(dd)
|
dates.append(dd)
|
||||||
durations.append(du)
|
durations.append(du)
|
||||||
types.append(w.workouttype)
|
types.append(w.workouttype)
|
||||||
|
rowers.append(w.user.user.first_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
d = utc.localize(startdate)
|
d = utc.localize(startdate)
|
||||||
@@ -250,17 +252,18 @@ def interactive_activitychart(workouts,startdate,enddate):
|
|||||||
dates.append(d.strftime('%m/%d'))
|
dates.append(d.strftime('%m/%d'))
|
||||||
durations.append(0)
|
durations.append(0)
|
||||||
types.append('rower')
|
types.append('rower')
|
||||||
|
rowers.append('Sander')
|
||||||
d += datetime.timedelta(days=1)
|
d += datetime.timedelta(days=1)
|
||||||
|
|
||||||
|
|
||||||
df = pd.DataFrame({
|
df = pd.DataFrame({
|
||||||
'date':dates,
|
'date':dates,
|
||||||
'duration':durations,
|
'duration':durations,
|
||||||
'type':types,
|
'type':types,
|
||||||
|
'rower':rowers,
|
||||||
})
|
})
|
||||||
|
|
||||||
p = Bar(df,'date',values='duration',title='Activity',
|
p = Bar(df,'date',values='duration',title='Activity',
|
||||||
stack='type',
|
stack=stack,
|
||||||
plot_width=350,
|
plot_width=350,
|
||||||
plot_height=250,
|
plot_height=250,
|
||||||
toolbar_location = None,
|
toolbar_location = None,
|
||||||
@@ -270,7 +273,7 @@ def interactive_activitychart(workouts,startdate,enddate):
|
|||||||
new_items = []
|
new_items = []
|
||||||
for legend_item in legend.items:
|
for legend_item in legend.items:
|
||||||
it = legend_item.label['value']
|
it = legend_item.label['value']
|
||||||
tot = df[df['type']==it].duration.sum()
|
tot = df[df[stack]==it].duration.sum()
|
||||||
if tot != 0:
|
if tot != 0:
|
||||||
new_items.append(legend_item)
|
new_items.append(legend_item)
|
||||||
legend.items = new_items
|
legend.items = new_items
|
||||||
|
|||||||
@@ -4416,9 +4416,15 @@ def workouts_view(request,message='',successmessage='',
|
|||||||
"-id"
|
"-id"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if theteam:
|
||||||
|
stack='rower'
|
||||||
|
else:
|
||||||
|
stack='type'
|
||||||
|
|
||||||
script,div = interactive_activitychart(g_workouts,
|
script,div = interactive_activitychart(g_workouts,
|
||||||
activity_startdate,
|
activity_startdate,
|
||||||
activity_enddate)
|
activity_enddate,
|
||||||
|
stack=stack)
|
||||||
|
|
||||||
messages.info(request,successmessage)
|
messages.info(request,successmessage)
|
||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
|
|||||||
Reference in New Issue
Block a user