Hi,
I’ve encountered a strange problem (actually two problems) when using Tap from bokeh.events (with the bokeh server).
In example 1 below, the Tap event works but also seems to work outside the right hand side of the plot area, up to the edge of the toolbar. If you click within the toolbar, the controls work, but it also updates the plot. You can also click below the toolbar and the plot updates.
In example 2 below (the plot appears after the button is pressed), the toolbar disappears when the plot (or toolbar) is tapped.
Does anyone know what’s going on?
Thanks,
Marcus.
Example 1
···
from bokeh.models.sources import ColumnDataSource
from bokeh.plotting import Figure
from bokeh.io import curdoc
from bokeh.events import Tap
fig = Figure()
line_src = ColumnDataSource(data={‘x’: [0, 1], ‘y’: [0, 1]})
line = fig.line(‘x’, ‘y’, source=line_src)
def update_data(event):
line_src.data[‘x’][1] = event.x
line_src.data[‘y’][1] = event.y
fig.renderers.remove(line)
fig.renderers.append(line)
fig.on_event(Tap, update_data)
curdoc().add_root(fig)
``
Example 2
from bokeh.models.sources import ColumnDataSource
from bokeh.models.layouts import Column, WidgetBox
from bokeh.models.widgets import Button, Div
from bokeh.plotting import Figure
from bokeh.io import curdoc
from bokeh.events import Tap
fig = Figure()
line_src = ColumnDataSource(data={‘x’: [0, 1], ‘y’: [0, 1]})
line = fig.line(‘x’, ‘y’, source=line_src)
def update_data(event):
line_src.data[‘x’][1] = event.x
line_src.data[‘y’][1] = event.y
fig.renderers.remove(line)
fig.renderers.append(line)
fig.on_event(Tap, update_data)
def update_plot():
gui.children[1] = fig
btn = Button(label=‘Click to plot’)
btn.on_click(update_plot)
gui = Column(WidgetBox(btn), Div())
curdoc().add_root(gui)
``