Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How DateRangeSlider in bokeh works?

I have been trying to work with dates in bokeh, but couldn't find a way, then I came across DateRangeSlider in bokeh but donot know the syntax how to initialze and use it. I need help in the working of DateRangeSlider in bokeh! Need Examples with code.

like image 832
Vamshi krishna Srirangam Avatar asked Jul 17 '17 12:07

Vamshi krishna Srirangam


1 Answers

from datetime import date

from bokeh.models.widgets import DateRangeSlider
from bokeh.layouts import layout

from bokeh.io import curdoc

date_range_slider = DateRangeSlider(title="Date Range: ", start=date(2017, 1, 1), end=date.today(), value=(date(2017, 9, 7), date(2017, 10, 15)), step=1)


l = layout(children=[[date_range_slider]], sizing_mode='fixed')
curdoc().add_root(l)
curdoc().title = "DateRangeSlider Example"

This should create a date range slider from Jan 1st 2017 to today (17th Oct 2017, in this case)

Below are the screenshots of this example:

Date Range Slider with the chosen default range Date Range Slider with the chosen default range

Date Range Slider with full range Date Range Slider with full range

For some reason, the start date sets to 01/01/2016 even though the specified value is 01/01/2017. When I set it to 2nd Jan, the year changes to 2017. I guess this is a bug.

EDIT: Works as expected in the latest version of bokeh.

like image 105
gvij Avatar answered Sep 22 '22 06:09

gvij