@Bryan thanks for the response. Here is an example app:
# file is main.py within a "simple-pointdraw" directory.
from bokeh.models import ColumnDataSource, PointDrawTool, CustomJS
from bokeh.plotting import figure
from bokeh.io import curdoc
from bokeh.layouts import row, layout
left = figure(x_range=(0, 10), y_range=(0, 10), tools=[],
title='Point Draw Tool')
left.background_fill_color = 'lightgrey'
right = figure(x_range=(0, 10), y_range=(0, 10), tools=[],
title='Synced Plot')
right.background_fill_color = 'lightgrey'
source = ColumnDataSource({
'x': [1, 5, 9],
'y': [1, 5, 9],
'y2': [2, 6, 10],
'color': ['red', 'green', 'yellow'],
})
js = """
for (var i = 0; i<cb_obj.data['y'].length; i++) {
var y = cb_obj.data['y'][i];
cb_obj.data['y2'][i] = y + 1;
}
cb_obj.change.emit();
"""
source.js_on_change('data', CustomJS(code=js))
left_renderer = left.scatter(x='x', y='y', source=source, color='color', size=10)
right_renderer = right.scatter(x='x', y='y2', source=source, color='color', size=10)
draw_tool = PointDrawTool(renderers=[left_renderer], empty_value='black')
left.add_tools(draw_tool)
left.toolbar.active_tap = draw_tool
curdoc().add_root(row(left, right))
curdoc().title = "Synced Plots"
Run using bokeh serve:
bokeh serve simple-pointdraw
The right plot gets updated y positions only after the point movement is complete. Is there a change.emit()
I need to set to see changes during point movement?