diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index d8d0c035..339b0bec 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -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 diff --git a/rowers/mytypes.py b/rowers/mytypes.py index 881cd311..50ec4541 100644 --- a/rowers/mytypes.py +++ b/rowers/mytypes.py @@ -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