unicode to str method
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user