The following code should define a bokeh app that consists of a single dateslider. If I save it as html ( serve=False
) it works as expected but the bokeh server returns a blank page. Any clues?
s = datetime.strptime('2019-01-01 14:00:00', '%Y-%m-%d %H:%M:%S')
e = datetime.strptime('2019-01-01 15:00:00', '%Y-%m-%d %H:%M:%S')
v = datetime.strptime('2019-01-01 14:01:00', '%Y-%m-%d %H:%M:%S')
st = timedelta(seconds=7)
slider = DateSlider(start=s, step=2, end=e, value=e, format='%Y-%m-%d %H:%M')
mylayout = column(children=[slider])
if serve:
curdoc().add_root(mylayout)
else:
fname = os.path.join(...)
output_file(fname)
save(mylayout)
Further questions:
timedelta
value here. All datetime values in Bokeh art typically in milliseconds, eg datetime axis values are milliseconds since epoch. Same in this case for intervals, eg here is an increment of 5 minutes:
from bokeh.models import DateSlider
from bokeh.io import curdoc
from bokeh.layouts import column
from datetime import datetime, timedelta
s = datetime.strptime('2019-01-01 14:00:00', '%Y-%m-%d %H:%M:%S')
e = datetime.strptime('2019-01-01 15:00:00', '%Y-%m-%d %H:%M:%S')
v = datetime.strptime('2019-01-01 14:01:00', '%Y-%m-%d %H:%M:%S')
st = timedelta(seconds=7)
slider = DateSlider(start=s, step=1000*60*5, end=e, value=e, format='%Y-%m-%d %H:%M')
mylayout = column(children=[slider])
curdoc().add_root(mylayout)
Having the step
accept timedelta
seems like a reasonable thing. Bokeh is huge project and many nice conveniences are not implemented simply because no one has ever pointed them out before. This would be a good issue to make aon GitHub, especially if you are interested in helping contribute.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.