OnReset event doesn't seem to happen every time reset button is pressed?

I’m trying to use the OnReset event to know when the user has pressed the reset button on the plot. If they do, I want to double-check that there isn’t new data in the database and possibly update the plot with that new data.

Unfortunately, OnReset only seems to arrive when the reset button also causes the plot contents to recenter itself.

Is that the expected behavior? Is there way to know when the reset button was pressed even if the bokeh library didn’t need to do anything with that button press?

AFAIK it should trigger unconditionally. But we’d need more information, i.e. relevant versions and a complete Minimal Reproducible Example to actually be able to investigate.

But regardless, based on your description, I’ll also mention CustomAction will allow you to add a custom button to the the toolbar and trigger a CustomJS whenever it is clicked.

Does the CustomAction callback have to be written in javascript or could I do it from python?

It only triggers a CustomJS, but that CustomJS could update a property on a DataModel to trigger an on_change I suppose.

I am trying to make a reproducible test case, but it seems to be some sort of interaction between my app, panel, and the panel Bokeh wrapper object.

A pure-bokeh program seems to give me my events, and a very simple panel app does as well.

But in my more-complicated app, when I swap out the bokeh object inside the Bokeh pane, some of the python event handlers aren’t called.

What is a DataModel? Is that like passing in ColumnDataSource as an argument to the JS callback?

Datamodels are a quick easy way to define your own custom models (that can have all the same on_change events, etc) without writing any extension code:

1 Like