Private
Public Access
1
0

activity chart improvements

This commit is contained in:
Sander Roosendaal
2021-05-31 13:34:14 +02:00
parent 9c2c55f697
commit 91718d4588
2 changed files with 32 additions and 6 deletions

View File

@@ -796,24 +796,38 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
dim_expr = hv.dim('type').categorize(mytypes.color_map)
df = pd.DataFrame(thedict)
if totaldays>30 and yaxis=='duration':
df['duration'] = df['duration']/60
elif yaxis == 'TRIMP':
df.drop('duration',inplace=True,axis=columns)
df.drop('rscore',inplace=True,axis=columns)
elif yaxis == 'rScore':
df.drop('duration',inplace=True,axis='columns')
df.drop('trimp',inplace=True,axis='columns' )
df['color'] = df['type'].apply(lambda x:mapcolors(x))
df.sort_values('date_sorting',inplace=True)
#clrs = hv.Cycle(df['colors'].values)
source = ColumnDataSource(df)
hv.extension('bokeh')
table = hv.Table(df,[('date','Date'),('type','Workout Type')],
[('duration','Minutes'),('trimp','TRIMP'),('rscore','rScore'),('link','link')])
bars=table.to.bars(['date',stack],[yaxis])
#table = hv.Table(df,[('date','Date'),('type','Workout Type')],
# [('duration','Minutes'),('trimp','TRIMP'),('rscore','rScore'),('link','link')])
types_order = mytypes.workouttypes_ordered
#bars=table.to.bars(['date',stack],[yaxis])
bars = hv.Bars(df, kdims=['date',stack]).aggregate(function=np.sum)
#print(mytypes.color_map)
bars.opts(
opts.Bars(cmap=mytypes.color_map, show_legend=True, stacked=True,
tools=['tap','hover'], width=550, xrotation=45,padding=(0,(0,.1)),
@@ -829,6 +843,18 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
d2 = enddate.strftime("%Y-%m-%d"),
)
p.xaxis.axis_label = 'Period'
if yaxis == 'duration':
p.yaxis.axis_label = 'Duration (min)'
if totaldays>30:
p.yaxis.axis_label = 'Duration (h)'
elif yaxis == 'TRIMP':
p.yaxis.axis_label = 'TRIMP'
else:
p.yaxis.axis_label = 'rScore'
p.plot_width=550
p.plot_height=350
p.toolbar_location = toolbar_location

View File

@@ -319,7 +319,7 @@ rowtypes = (
)
checktypes = [i[0] for i in workouttypes]
checktypes = [i[0] for i in workouttypes_ordered.items()]
from bokeh.palettes import Category10,Category20, Category20c