adding bar chart
This commit is contained in:
@@ -26,7 +26,7 @@ from bokeh.models import CustomJS,Slider, TextInput,BoxAnnotation
|
||||
from bokeh.resources import CDN,INLINE
|
||||
from bokeh.embed import components
|
||||
from bokeh.layouts import layout,widgetbox
|
||||
from bokeh.palettes import Category20c
|
||||
from bokeh.palettes import Category20c,Category10
|
||||
from bokeh.layouts import row as layoutrow
|
||||
from bokeh.layouts import column as layoutcolumn
|
||||
from bokeh.models import LinearAxis,LogAxis,Range1d,DatetimeTickFormatter,HoverTool
|
||||
@@ -278,7 +278,7 @@ def interactive_workouttype_piechart(workouts):
|
||||
data = pd.Series(datadict).reset_index(name='value').rename(columns={'index':'type'})
|
||||
data['angle'] = data['value']/data['value'].sum() * 2*pi
|
||||
if len(datadict)>2:
|
||||
data['color'] = Category20c[len(datadict)]
|
||||
data['color'] = Category10[len(datadict)]
|
||||
elif len(datadict)==2:
|
||||
data['color'] = ['orange','lightblue']
|
||||
else:
|
||||
@@ -414,6 +414,13 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
||||
seen = ['seen']
|
||||
idseen = []
|
||||
|
||||
startdate = datetime.datetime(year=startdate.year,month=startdate.month,day=startdate.day)
|
||||
enddate = datetime.datetime(year=enddate.year,month=enddate.month,day=enddate.day)
|
||||
|
||||
duration = enddate-startdate
|
||||
|
||||
totaldays = duration.total_seconds()/(24*3600)
|
||||
|
||||
|
||||
for w in workouts:
|
||||
aantal=1
|
||||
@@ -432,9 +439,15 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
||||
for w in workouts:
|
||||
dd = w.date.strftime('%m/%d')
|
||||
dd2 = w.date.strftime('%Y/%m/%d')
|
||||
dd3 = w.date.strftime('%Y/%m')
|
||||
du = w.duration.hour*60+w.duration.minute
|
||||
dates.append(dd)
|
||||
dates_sorting.append(dd2)
|
||||
|
||||
if totaldays<30:
|
||||
dates.append(dd)
|
||||
dates_sorting.append(dd2)
|
||||
else:
|
||||
dates.append(dd3)
|
||||
dates_sorting.append(dd3)
|
||||
durations.append(du)
|
||||
links.append(
|
||||
"{siteurl}/rowers/workout/{code}/".format(
|
||||
@@ -451,21 +464,25 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
||||
|
||||
try:
|
||||
d = utc.localize(startdate)
|
||||
except ValueError:
|
||||
except (ValueError,AttributeError):
|
||||
d = startdate
|
||||
|
||||
try:
|
||||
enddate = utc.localize(enddate)
|
||||
except ValueError:
|
||||
except (ValueError,AttributeError):
|
||||
pass
|
||||
|
||||
# add dates with no activity
|
||||
while d<=enddate:
|
||||
dd = d.strftime('%d')
|
||||
dates.append(d.strftime('%m/%d'))
|
||||
|
||||
|
||||
dates_sorting.append(d.strftime('%Y/%m/%d'))
|
||||
if totaldays<30:
|
||||
dates.append(d.strftime('%m/%d'))
|
||||
dates_sorting.append(d.strftime('%Y/%m/%d'))
|
||||
else:
|
||||
dates.append(d.strftime('%Y/%m'))
|
||||
dates_sorting.append(d.strftime('%Y/%m'))
|
||||
durations.append(0)
|
||||
links.append('')
|
||||
types.append('rower')
|
||||
@@ -489,6 +506,9 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_lo
|
||||
'link':links,
|
||||
}
|
||||
|
||||
types_ind = list(set(types))
|
||||
|
||||
|
||||
df = pd.DataFrame(thedict)
|
||||
|
||||
source = ColumnDataSource(df)
|
||||
|
||||
Reference in New Issue
Block a user