Hi Bryan et al,
I’m trying to get a CustomJS callback in a TapTool to update a ColumnDataSource but it doesn’t seem to be working. Code below. In the browser console log I can see the list of x coordinates being updated when I tap on the line, but the server console readout doesn’t show the same data - the CDS list remains empty. Am I missing something or is this a bug? I’m running v0.12.6 on Ubuntu MATE 16.04.2, Firefox 54.0.
Thanks,
Marcus.
from bokeh.models.sources import ColumnDataSource
from bokeh.models.tools import TapTool
from bokeh.models.callbacks import CustomJS
from bokeh.plotting import Figure
from bokeh.io import curdoc
src = ColumnDataSource(data={‘x’: })
js = ‘’’
var geom = cb_data[‘geometries’];
var data = source.get(‘data’);
var tx = geom[0].x;
var x = data[‘x’];
x.push(tx);
data[‘x’] = x;
source.trigger(‘change’);
console.log(source.get(‘data’)[‘x’]);
‘’’
cjs = CustomJS(args={‘source’: src}, code=js)
tap_tool = TapTool(callback=cjs)
plot = Figure(x_axis_label=‘x’, y_axis_label=‘y’,
plot_width=400, plot_height=400,
x_range=[0, 1], y_range=[0, 1],
tools=[tap_tool])
plot.line([0, 1], [0, 1], line_width=2)
def update():
print(src.data[‘x’])
curdoc().add_root(plot)
curdoc().add_periodic_callback(update, 1000)