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.plotting import figure, ColumnDataSource, Figure,curdoc
|
||||||
from bokeh.models import CustomJS,Slider, TextInput,BoxAnnotation
|
from bokeh.models import CustomJS,Slider, TextInput,BoxAnnotation
|
||||||
from bokeh.charts import Histogram,HeatMap,Area,BoxPlot,Bar
|
from bokeh.charts import Histogram,HeatMap,Area,BoxPlot,Bar
|
||||||
|
from bokeh.charts.attributes import CatAttr
|
||||||
from bokeh.resources import CDN,INLINE
|
from bokeh.resources import CDN,INLINE
|
||||||
from bokeh.embed import components
|
from bokeh.embed import components
|
||||||
from bokeh.layouts import layout,widgetbox
|
from bokeh.layouts import layout,widgetbox
|
||||||
@@ -227,6 +228,7 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
|||||||
return "",""
|
return "",""
|
||||||
|
|
||||||
dates = []
|
dates = []
|
||||||
|
dates_sorting = []
|
||||||
types = []
|
types = []
|
||||||
rowers = []
|
rowers = []
|
||||||
durations = []
|
durations = []
|
||||||
@@ -234,8 +236,10 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
|||||||
for w in workouts:
|
for w in workouts:
|
||||||
if w.privacy == 'visible':
|
if w.privacy == 'visible':
|
||||||
dd = w.date.strftime('%m/%d')
|
dd = w.date.strftime('%m/%d')
|
||||||
|
dd2 = w.date.strftime('%Y/%m/%d')
|
||||||
du = w.duration.hour*60+w.duration.minute
|
du = w.duration.hour*60+w.duration.minute
|
||||||
dates.append(dd)
|
dates.append(dd)
|
||||||
|
dates_sorting.append(dd2)
|
||||||
durations.append(du)
|
durations.append(du)
|
||||||
types.append(w.workouttype)
|
types.append(w.workouttype)
|
||||||
try:
|
try:
|
||||||
@@ -253,9 +257,10 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# add dates with no activity
|
||||||
while d<=enddate:
|
while d<=enddate:
|
||||||
dates.append(d.strftime('%m/%d'))
|
dates.append(d.strftime('%m/%d'))
|
||||||
|
dates_sorting.append(d.strftime('%Y/%m/%d'))
|
||||||
durations.append(0)
|
durations.append(0)
|
||||||
types.append('rower')
|
types.append('rower')
|
||||||
rowers.append('Sander')
|
rowers.append('Sander')
|
||||||
@@ -263,12 +268,19 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
|||||||
|
|
||||||
df = pd.DataFrame({
|
df = pd.DataFrame({
|
||||||
'date':dates,
|
'date':dates,
|
||||||
|
'date_sorting':dates_sorting,
|
||||||
'duration':durations,
|
'duration':durations,
|
||||||
'type':types,
|
'type':types,
|
||||||
'rower':rowers,
|
'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,
|
stack=stack,
|
||||||
plot_width=350,
|
plot_width=350,
|
||||||
plot_height=250,
|
plot_height=250,
|
||||||
|
|||||||
@@ -2957,9 +2957,15 @@ def histo(request,theuser=0,
|
|||||||
if 'options' in request.session:
|
if 'options' in request.session:
|
||||||
options = request.session['options']
|
options = request.session['options']
|
||||||
|
|
||||||
workouttypes = options['workouttypes']
|
try:
|
||||||
includereststrokes = options['includereststrokes']
|
workouttypes = options['workouttypes']
|
||||||
waterboattype = options['waterboattype']
|
includereststrokes = options['includereststrokes']
|
||||||
|
waterboattype = options['waterboattype']
|
||||||
|
except KeyError:
|
||||||
|
workouttypes = ['water','rower','dynamic','slides']
|
||||||
|
waterboattype = ['1x','2x','2-','4x','4-','8+']
|
||||||
|
includereststrokes = False
|
||||||
|
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
|
|
||||||
|
|
||||||
@@ -5760,15 +5766,25 @@ def boxplot_view_data(request,userid=0,
|
|||||||
|
|
||||||
if 'options' in request.session:
|
if 'options' in request.session:
|
||||||
options = request.session['options']
|
options = request.session['options']
|
||||||
|
|
||||||
includereststrokes = options['includereststrokes']
|
try:
|
||||||
spmmin = options['spmmin']
|
includereststrokes = options['includereststrokes']
|
||||||
spmmax = options['spmmax']
|
spmmin = options['spmmin']
|
||||||
workmin = options['workmin']
|
spmmax = options['spmmax']
|
||||||
workmax = options['workmax']
|
workmin = options['workmin']
|
||||||
ids = options['ids']
|
workmax = options['workmax']
|
||||||
userid = options['userid']
|
ids = options['ids']
|
||||||
plotfield = options['plotfield']
|
userid = options['userid']
|
||||||
|
plotfield = options['plotfield']
|
||||||
|
except KeyError:
|
||||||
|
includereststrokes = False
|
||||||
|
spmmin = 15
|
||||||
|
spmmax = 55
|
||||||
|
workmin = 0
|
||||||
|
workmax = 55
|
||||||
|
ids = []
|
||||||
|
userid = 0
|
||||||
|
plotfield = 'spm'
|
||||||
|
|
||||||
|
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
@@ -5840,8 +5856,13 @@ def boxplot_view(request,userid=0,
|
|||||||
|
|
||||||
if 'options' in request.session:
|
if 'options' in request.session:
|
||||||
options = request.session['options']
|
options = request.session['options']
|
||||||
|
|
||||||
|
try:
|
||||||
|
includereststrokes = options['includereststrokes']
|
||||||
|
except KeyError:
|
||||||
|
includereststrokes = False
|
||||||
|
options['includereststrokes'] = False
|
||||||
|
|
||||||
includereststrokes = options['includereststrokes']
|
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
|
|
||||||
if userid==0:
|
if userid==0:
|
||||||
@@ -5960,7 +5981,6 @@ def workouts_view(request,message='',successmessage='',
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
activity_enddate = enddate
|
activity_enddate = enddate
|
||||||
|
|
||||||
|
|
||||||
if teamid:
|
if teamid:
|
||||||
try:
|
try:
|
||||||
theteam = Team.objects.get(id=teamid)
|
theteam = Team.objects.get(id=teamid)
|
||||||
@@ -6027,7 +6047,7 @@ def workouts_view(request,message='',successmessage='',
|
|||||||
stack='rower'
|
stack='rower'
|
||||||
else:
|
else:
|
||||||
stack='type'
|
stack='type'
|
||||||
|
|
||||||
script,div = interactive_activitychart(g_workouts,
|
script,div = interactive_activitychart(g_workouts,
|
||||||
activity_startdate,
|
activity_startdate,
|
||||||
activity_enddate,
|
activity_enddate,
|
||||||
|
|||||||
Reference in New Issue
Block a user