Displaying annotations when an event callback runs

I want to display annotations when an event callback runs
I tried:

cds1= ColumnDataSource(data=dict(x_start=, y_start=, x_end=, y_end= ))
p.add_layout(Arrow(end=VeeHead(size=8), line_color=“grey”, source=cds1, x_start=‘x_start’, y_start=‘y_start’, x_end=‘x_end’, y_end=‘y_end’))

in callback:
cds1.data=dict(x_start=x_start_arr, y_start=y_start_arr, x_end=x_end_arr, y_end=y_end_arr )

I expected all arrows to be seen, when I injected data into cds1.data. But none of them are seen.

What am I doing wrong?


Hi @ahmettemiz88

A few things to check/confirm quickly. If these do not uncover the problem, you’ll probably be asked to provide more information including a minimum reproducible example of what is not working.

  1. From the data assignment statement, I surmise you’re using a Python callback. If so, you need to be running bokeh as a server via bokeh serve ... See this part of the documentation that makes it explicit

Alternatively it is possible to trigger Python code to run when events happen, in the context of a Bokeh application running on a Bokeh server. This can accomplished by passing an event class, and a callback function to the the on_event() method. The callback should accept a single argument event , which will be passed the concrete event object that triggered the callback.

  1. If you are running as a bokeh server and using a callback such as on_event(), what is the event you’ve registered with the callback and do you see the callback actually being invoked?