bokeh DatePicker value format inconsistent
See original GitHub issueI have two DatePicker widgets and I am trying to pass the DatePicker values thru the URL when the user changes the DatePicker value, and I am seeing odd behavior. The DatePicker date format toggles between a string and an epoch when I change the other DatePicker. Best shown by example, here are two URLs that are produced when I change each DatePicker,
http://127.0.0.1:6800/?start_date=1529424998666&end_date=Tue Jun 19 2018 http://127.0.0.1:6800/?start_date=Fri Jun 08 2018&end_date=1529512006618
Browser: Chrome Host OS: Windows 10 Python: 2.7.11
from datetime import datetime, timedelta
from bokeh.embed import components
from bokeh.models.widgets.inputs import DatePicker
from bokeh.models.callbacks import CustomJS
from bokeh.layouts import column
from flask import Flask
app = Flask(__name__)
@app.route("/", methods=['GET'])
def test():
text = """<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://cdn.pydata.org/bokeh/release/bokeh-0.12.15.min.css" rel="stylesheet" type="text/css">
<script src="https://cdn.pydata.org/bokeh/release/bokeh-0.12.15.min.js"></script>
<link href="https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.15.min.css" rel="stylesheet" type="text/css">
<script src="https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.15.min.js"></script>
<meta charset="UTF-8">
</head>
<body>"""
d_yesterday = datetime.today() - timedelta(days=1)
d_year_ago = datetime.today() - timedelta(days=365)
datepicker_start = DatePicker(title="Start Date", min_date=d_year_ago, max_date=datetime.now(), value=d_yesterday)
datepicker_end = DatePicker(title="End Date", min_date=d_year_ago, max_date=datetime.today(), value=datetime.today())
all_callback = CustomJS(args=dict(d_start=datepicker_start, d_end=datepicker_end), code="""
function encodeQueryData(data) {
let ret = [];
for (let d in data)
ret.push(encodeURIComponent(d) + '=' + encodeURIComponent(data[d]));
return ret.join('&');
}
var params = {'start_date': d_start.value, 'end_date': d_end.value }
var url = '/?' + encodeQueryData(params)
window.location.replace(url);
""")
datepicker_start.callback = all_callback
datepicker_end.callback = all_callback
layout = column(datepicker_start, datepicker_end)
_script, _div = components(layout)
text += "{}{}".format(_script, _div)
text += """
</body></html>
"""
return text
app.run(host="0.0.0.0", port=6800)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
DatePicker value change - Bokeh Discourse
I want to update the value of DatePicker widget. time = widgets.inputs. ... The same problem arises when you change min_date, max_date. The...
Read more >Updating ColumnDataSource using a DatePicker widget
I have a Bokeh server application that is using a ColumnDataSource and two DatePicker widgets for a vbar_stack plot.
Read more >Performance and Debugging — Panel v0.14.2rc1
This means that if the specified number of max_items is reached Panel will automatically evict items from the cache based on this policy...
Read more >Building Dashboards Using Bokeh - CODE Magazine
Based on the value of the ncols parameter, Bokeh automatically lays out your plot from left to right, top to bottom, as shown...
Read more >How to Link Bokeh Charts with IPywidgets widgets to ...
import bokeh print("Bokeh Version : {}".format(bokeh.__version__)) ... DatePicker(value=start_date) end_date_picker = ipywidgets.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also noticed that the datepicker can be one day off from what the user selected when using the callback. And the date sliders also have inconsistent formats, epoch and string.
I am fixing this in a PR for #8934