Private
Public Access
1
0

unicode to str method

This commit is contained in:
Sander Roosendaal
2019-02-25 20:21:21 +01:00
parent e543411dbc
commit 199382a700
2 changed files with 63 additions and 38 deletions

View File

@@ -246,6 +246,9 @@ def interactive_boxchart(datadf,fieldname,extratitle=''):
return script,div
import holoviews as hv
hv.extension('bokeh')
renderer = hv.renderer('bokeh')
def interactive_activitychart(workouts,startdate,enddate,stack='type'):
@@ -321,8 +324,8 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
df.sort_values('date_sorting',inplace=True)
p = Bar(df,values='duration',
label = CatAttr(columns=['date'], sort=False),
p = hv.Bars(df,values='duration',
# label = CatAttr(columns=['date'], sort=False),
xlabel='Date',
ylabel='Time',
title='Activity {d1} to {d2}'.format(
@@ -336,24 +339,29 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
)
for legend in p.legend:
new_items = []
for legend_item in legend.items:
it = legend_item.label['value']
tot = df[df[stack]==it].duration.sum()
if tot != 0:
new_items.append(legend_item)
legend.items = new_items
# for legend in p.legend:
# new_items = []
# for legend_item in legend.items:
# it = legend_item.label['value']
# tot = df[df[stack]==it].duration.sum()
# if tot != 0:
# new_items.append(legend_item)
# legend.items = new_items
p.legend.location = "top_left"
p.legend.background_fill_alpha = 0.7
# p.legend.location = "top_left"
# p.legend.background_fill_alpha = 0.7
#p.sizing_mode = 'scale_width'
p.sizing_mode = 'stretch_both'
#p.sizing_mode = 'stretch_both'
p.yaxis.axis_label = 'Minutes'
script, div = components(p)
#p.yaxis.axis_label = 'Minutes'
try:
p = renderer.get_plot(p).state
script, div = components(p)
except:
script = ''
div = ''
return script,div