Dear bokeh community,
I am trying to use python callback triggered by SelectionGeometry event on image_rgba but it is very slow. Tried the same using js callback and it works nicely.
This behaviour is present both for lasso_select and box_select.
Tried on safari and chrome, using bokeh version 2.3.1
Code example
from bokeh.models import CustomJS
from bokeh.plotting import figure, output_notebook, show
from bokeh.events import SelectionGeometry
from bokeh.application import Application
from bokeh.application.handlers import FunctionHandler
import numpy as np
output_notebook()
# Choose 'python' or 'js'
case = 'python'
def f(doc):
N = 1000
img = np.empty((N,N), dtype=np.uint32)
view = img.view(dtype=np.uint8).reshape((N, N, 4))
for i in range(N):
for j in range(N):
view[i, j, 0] = int(i/N*255)
view[i, j, 1] = 158
view[i, j, 2] = int(j/N*255)
view[i, j, 3] = 255
plot = figure(tools="lasso_select, box_select, wheel_zoom")
plot.image_rgba(image=[img], x=0, y=0, dw=10, dh=10)
if case == 'python':
plot.on_event(SelectionGeometry, lambda x: None)
else:
plot.js_on_event(SelectionGeometry, CustomJS(code=""" """))
doc.add_root(plot)
return doc
handler = FunctionHandler(f)
app = Application(handler)
show(app)
Here is the screenshot of desired result.
Am I doing something wrong ?
Thank you,
Ben


