So, the error I had before
document.js:412 Uncaught Error: reference {“id”:“58779667-2eb0-40c1-ab52-d3b1928cd2a0”,“type”:“Div”} isn’t known (not in Document?)
happens at
plot.js_on_event(‘reset’, callback)
as the message suggests I tried to configure the callback after adding the Div widget to the bokeh document, like this:
But then I get another error in the JS console:
connection.js:178 [bokeh] Failed to repull session Error: reference {“id”:“338aa405-4f2e-4292-b044-a63141bd2c38”,“type”:“CustomJS”} isn’t known (not in Document?)
and this time the app does not show up in the browser.
In both cases I’m running the server with --log-level debug but there’s nothing in the bokeh server logs.
$ bokeh serve --log-level debug app.py
I would appreciate any help to understand what is going on.
thanks,
···
from bokeh.io import curdoc
from bokeh.plotting import figure
from bokeh.models.callbacks import CustomJS
from bokeh.models.widgets import Div
from bokeh.layouts import widgetbox, column
title = Div(text=“”)
plot = figure()
callback = CustomJS(args={‘title’: title}, code=“”“title.text=‘Reset event ocurred.’”“”)
layout = column(widgetbox(title), plot)
curdoc().add_root(layout)
plot.js_on_event(‘reset’, callback) # moved this line to here
On Fri, Jul 20, 2018 at 5:03 PM, Angelo Fausti [email protected] wrote:
Angelo Fausti
So, the following code works, I managed to update the Div text property when the plot reset tool is used. But I am getting this error in the JS console:
document.js:412 Uncaught Error: reference {“id”:“58779667-2eb0-40c1-ab52-d3b1928cd2a0”,“type”:“Div”} isn’t known (not in Document?)
why is that?
thanks,
from bokeh.io import curdoc
from bokeh.plotting import figure
from bokeh.models.callbacks import CustomJS
from bokeh.models.widgets import Div
from bokeh.layouts import widgetbox, column
title = Div(text=“”)
plot = figure()
callback = CustomJS(args={‘title’: title}, code=“”“title.text=‘Reset event ocurred.’”“”)
plot.js_on_event(‘reset’, callback)
layout = column(widgetbox(title), plot)
curdoc().add_root(layout)
I would like to do something similar in my bokeh application that’s why I am running with bokeh server.
Bokeh version 0.13.0
Angelo Fausti
On Fri, Jul 20, 2018 at 2:51 PM, Angelo Fausti [email protected] wrote:
Hi,
I have CustomJS calback attached to a datasource that I use to recompute an average whenever the selection changes.
http://bokeh.pydata.org/en/latest/docs/user_guide/interaction/callbacks.html#customjs-for-model-property-events
self.pcircle.data_source.on_change(‘selected’, self.calculate_avg_temp)
def calculate_avg_temp(self, attr, old, new):
index = new[‘1d’][‘indices’]
if len(index) == 0:
return
index.sort()
self.update_ave_temp(np.mean(np.array(self.cds.data[‘temperatures’])[index]))
and it works fine.
Then I would like to clear the selection and reset the average value.
Can I use a CustomJS callback for the plot reset tool? is there an example for that? or do you recommend another method.
thank you,
Angelo Fausti