activity chart improvements
This commit is contained in:
@@ -796,24 +796,38 @@ def interactive_activitychart2(workouts,startdate,enddate,stack='type',toolbar_l
|
|||||||
|
|
||||||
dim_expr = hv.dim('type').categorize(mytypes.color_map)
|
dim_expr = hv.dim('type').categorize(mytypes.color_map)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
df = pd.DataFrame(thedict)
|
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['color'] = df['type'].apply(lambda x:mapcolors(x))
|
||||||
|
|
||||||
df.sort_values('date_sorting',inplace=True)
|
df.sort_values('date_sorting',inplace=True)
|
||||||
|
|
||||||
#clrs = hv.Cycle(df['colors'].values)
|
#clrs = hv.Cycle(df['colors'].values)
|
||||||
source = ColumnDataSource(df)
|
source = ColumnDataSource(df)
|
||||||
|
|
||||||
hv.extension('bokeh')
|
hv.extension('bokeh')
|
||||||
|
|
||||||
|
|
||||||
table = hv.Table(df,[('date','Date'),('type','Workout Type')],
|
#table = hv.Table(df,[('date','Date'),('type','Workout Type')],
|
||||||
[('duration','Minutes'),('trimp','TRIMP'),('rscore','rScore'),('link','link')])
|
# [('duration','Minutes'),('trimp','TRIMP'),('rscore','rScore'),('link','link')])
|
||||||
|
|
||||||
|
types_order = mytypes.workouttypes_ordered
|
||||||
bars=table.to.bars(['date',stack],[yaxis])
|
#bars=table.to.bars(['date',stack],[yaxis])
|
||||||
|
bars = hv.Bars(df, kdims=['date',stack]).aggregate(function=np.sum)
|
||||||
|
|
||||||
|
|
||||||
|
#print(mytypes.color_map)
|
||||||
bars.opts(
|
bars.opts(
|
||||||
opts.Bars(cmap=mytypes.color_map, show_legend=True, stacked=True,
|
opts.Bars(cmap=mytypes.color_map, show_legend=True, stacked=True,
|
||||||
tools=['tap','hover'], width=550, xrotation=45,padding=(0,(0,.1)),
|
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"),
|
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_width=550
|
||||||
p.plot_height=350
|
p.plot_height=350
|
||||||
p.toolbar_location = toolbar_location
|
p.toolbar_location = toolbar_location
|
||||||
|
|||||||
@@ -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
|
from bokeh.palettes import Category10,Category20, Category20c
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user