bug fix order of activity chart
This commit is contained in:
@@ -13,6 +13,7 @@ import itertools
|
||||
from bokeh.plotting import figure, ColumnDataSource, Figure,curdoc
|
||||
from bokeh.models import CustomJS,Slider, TextInput,BoxAnnotation
|
||||
from bokeh.charts import Histogram,HeatMap,Area,BoxPlot,Bar
|
||||
from bokeh.charts.attributes import CatAttr
|
||||
from bokeh.resources import CDN,INLINE
|
||||
from bokeh.embed import components
|
||||
from bokeh.layouts import layout,widgetbox
|
||||
@@ -227,6 +228,7 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
||||
return "",""
|
||||
|
||||
dates = []
|
||||
dates_sorting = []
|
||||
types = []
|
||||
rowers = []
|
||||
durations = []
|
||||
@@ -234,8 +236,10 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
||||
for w in workouts:
|
||||
if w.privacy == 'visible':
|
||||
dd = w.date.strftime('%m/%d')
|
||||
dd2 = w.date.strftime('%Y/%m/%d')
|
||||
du = w.duration.hour*60+w.duration.minute
|
||||
dates.append(dd)
|
||||
dates_sorting.append(dd2)
|
||||
durations.append(du)
|
||||
types.append(w.workouttype)
|
||||
try:
|
||||
@@ -253,9 +257,10 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
|
||||
# add dates with no activity
|
||||
while d<=enddate:
|
||||
dates.append(d.strftime('%m/%d'))
|
||||
dates_sorting.append(d.strftime('%Y/%m/%d'))
|
||||
durations.append(0)
|
||||
types.append('rower')
|
||||
rowers.append('Sander')
|
||||
@@ -263,12 +268,19 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
||||
|
||||
df = pd.DataFrame({
|
||||
'date':dates,
|
||||
'date_sorting':dates_sorting,
|
||||
'duration':durations,
|
||||
'type':types,
|
||||
'rower':rowers,
|
||||
})
|
||||
|
||||
df.sort_values('date_sorting',inplace=True)
|
||||
|
||||
p = Bar(df,'date',values='duration',title='Activity',
|
||||
p = Bar(df,values='duration',
|
||||
label = CatAttr(columns=['date'], sort=False),
|
||||
xlabel='Date',
|
||||
ylabel='Time',
|
||||
title='Activity',
|
||||
stack=stack,
|
||||
plot_width=350,
|
||||
plot_height=250,
|
||||
|
||||
Reference in New Issue
Block a user