tap tool on bokeh server does not select data points with a custom callback
See original GitHub issueVersions: Firefox 54.0.1 (64-bit) on macOS Sierra, 0.12.6
Expected behavior: With the tap tool, the user can select a data point and the specified callback will fire
Observed behavior: Callback fires intermittently with incorrect parameters, or does not fire at all
mwe.py
:
from bokeh import plotting as bplt
from bokeh import layouts as blayouts
from bokeh import models as bmodels
from bokeh import io as bio
fig = bplt.figure(tools="tap")
source = bmodels.ColumnDataSource(dict(x=[0,1], y=[0,1]))
r = fig.circle('x', 'y', source=source, size=4)
def handler(attr, old, new):
print('attr: {} old: {} new: {}'.format(attr, old, new))
r.data_source.on_change('selected', handler)
bio.curdoc().add_root(blayouts.layout([[fig]]))
bokeh serve --show mwe.py
Steps to reproduce
- Run
bokeh serve --show mwe.py
as above - Click one of the circles
- Observe that either i) no output is printed, or ii) the following is printed, indicating the callback fired with incorrect empty arguments:
attr: selected old: {'0d': {'glyph': None, 'indices': []}, '1d': {'indices': []}, '2d': {'indices': {}}} new: {'0d': {'glyph': None, 'get_view': {}, 'indices': []}, '1d': {'indices': []}, '2d': {'indices': {}}}
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
How to create a Bokeh Tap tool to select all points of the ...
Here is an example solution using CustomJS with bokeh 0.12.6. Essentially when the user selects a glyph, you know which row that corresponds ......
Read more >JavaScript callbacks — Bokeh 2.4.3 Documentation
The HoverTool has a callback which comes with two pieces of built-in data: the index and the geometry . The index is the...
Read more >Interactive Data Visualization with Bokeh - Trenton McKinney
Bokeh is an interactive data visualization library for Python, and other languages, that targets modern web browsers for presentation.
Read more >Bokeh: CustomJS and Callbacks - YouTube
In order for a widget to be useful, it needs to be able to perform some action. Using the Bokeh server, it is...
Read more >Adding Interactions - Bokeh documentation
When used with the Bokeh server, widgets can run arbitrary Python code, ... tools="tap", title="Click the Dots") source = ColumnDataSource(data=dict( x=[1, ...
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 can reproduce on Google Chrome. A couple of things that I notice:
size
- otherwise, it’s way too easy to miss a pointget_view
. Probably it’s a function that gets added to the selection result dynamically, resulting in this diffget_view
and the correct dot indexI updated the code to the current standard usage:
and tested on Chrome, FF, and Safari. The circles were a bit hard to hit (because they are tiny) but in every case the callback printed exactly what is expected. There were lots of issues previously with both the “dict” for selections, and also with Bokeh itself replacing whole
Selection
objects. My guess is this issue was related to those things as well (neither of them exists anymore)