What is the event sent when a plot is refreshed

hi
i want to add a callback after a figure is refreshed when the associated column data source has its data changed.
i dont think cds.on_change(‘data’, cb) is the correct way because i want an event launched from the plot on client side.
thanks

There is not currently such any event exposed for plot refresh. If you can describe what you are actually trying to accomplish at a high level, without assuming a particular solution (e.g. a “plot refresh” event), there might be other alternatives we can suggest.

I want to plot last N samples of a data stream. I don’t want to use a push model, i.e updating cds data every seconds. I want to use a pull model, updating cds only when the plot has finished to display the previous data.

You could use an AjaxDataSource to poll a remote endpoint on a fixed interval, I am afraid that is the closest suggestion I have.

I’m not sure if I correctly understand you but MAYBE, this same post is relevant to you: Scatter markers time series plot interacting too slow - #6 by Cosmidark

thanks Bryan
I think ajax solution is too complex to implement on my side.
Finally, i only need the event sent when a plot is updated in the browser.
If i does not exist, is it complicated to implement it ? Do you know where i should look first in the bokeh source tree ?
i found source.js_on_change(‘streaming’, cb). May be is good enough for me.
In the documentation, i saw the following steps in the propagation of an event
‘’
user invokes Document API
→ Document API triggers event objects
→ registered callbacks are executed
→ Sesssion callback generates JSON message from event object
→ Session sends JSON message over websocket

Session recieves JSON message over websocket
→ Document calls event.handle_json
→ handle_json invokes appropriate Document API
→ Document API triggers event objects
→ registered callbacks are executed
→ Session callback suppresses outgoing event
‘’
when i do a cds.data or a cds.stream(), does it mean that all these steps have been executed synchronously ?
or is there a stack or queue somewhere between two steps ? I mean if i do plenty of cds.data, where a ‘stack overflow’ appears ?
thanks

Finally, i only need the event sent when a plot is updated in the browser.

As I said above, this does not exist.

If i does not exist, is it complicated to implement it ? Do you know where i should look first in the bokeh source tree ?

It’s not enormous work, but it is also not trivial. As an example, here is the PR the added the RangesUpdate event:

Add RangesUpdate event by bryevdv · Pull Request #11125 · bokeh/bokeh · GitHub

Adding a “render finished” event, including tests, would probably be a comparable effort. Note that:

  • Given our current release cadence, this new feature would not make it into a published release for another 3-6 months.
  • There would need to be core dev agreement that it is good to add at all.

i found source.js_on_change(‘streaming’, cb).

Where? This was a mostly experimental feature in old versions of Bokeh. AFAIK it does not exist any longer in modern versions. cc @mateusz

when i do a cds.data or a cds.stream(), does it mean that all these steps have been executed synchronously ?

Bokeh throttles the rendering step and combines updates within the throttle window, so no.

To be honest, if eventing exactly on plot render is a hard and fast requirement for you, you might want to look at other tools.