You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python version : 3.12.0 | packaged by conda-forge | (main, Oct 3 2023, 08:26:13) [MSC v.1935 64 bit (AMD64)]
IPython version : 8.16.1
Tornado version : 6.3.3
Bokeh version : 3.3.0
BokehJS static path : C:\Users\XXX\miniconda3\envs\myenv312\Lib\site-packages\bokeh\server\static
node.js version : (not installed)
npm version : (not installed)
Operating system : Windows-10-10.0.19045-SP0
Browser name and version
Chrome Version 120.0.6099.71 (Offizieller Build) (64-Bit)
Jupyter notebook / Jupyter Lab version
No response
Expected behavior
In the following code, I change the source of a plot renderer in a callback.
For performance reasons (which don’t play a role in this minimal example), I first remove the plot from the layout, apply the change and then put the plot back to the layout.
This works fine, but as expected I get a blinking which I would like to avoid, so I use curdoc().hold() - curdoc().unhold().
I would then expect the display to update after curdoc().unhold(), in my example the plot should go to 5000.
Observed behavior
After curdoc().unhold(), the update is not shown.
Also, I get a JavaScript console warning reference already known 'p1002', P1002 being the id of the plot.
Example code
importnumpyasnpfrombokeh.ioimportcurdocfrombokeh.plottingimportfigure, showfrombokeh.layoutsimportColumnfrombokeh.modelsimportButton, ColumnDataSourcebutton=Button(label="Click")
p=figure(width=400, height=400, title="Title")
small_array=np.arange(1000)
small_dict=dict(x=small_array, y=small_array)
source=ColumnDataSource(small_dict)
big_array=np.arange(50000) # <- Increase this number if the change is too quick on your machinebig_dict=dict(x=big_array, y=big_array)
p.circle(source=source)
defcallback():
curdoc().hold() # <- Togglelayout.children= [button]
p.title.text="New title"p.renderers[0].data_source.data=big_dictlayout.children.append(p)
curdoc().unhold() # <- Togglebutton.on_click(callback)
layout=Column(button, p)
curdoc().add_root(layout)
I think the problem here is that when you remove the plot from the layout the property changes on it are no longer tracked this means your updates to the plot do not trigger change events. When you re-add the plot to the layout it internally combines the two change events to the children (dropping the event that removes the plot). When you call unhold only the single Column.children event is sent to the frontend and since that already has a full representation of your plot the event is ignored. You might try changing the hold policy from "combine" to "collect" in the curdoc.hold(policy='collect') call.
This seems like a potentially general problem with the serializer. @mattpap In a case like this where a reference is already known could we not apply the updated property values from the new reference to the existing model or is that too complex for nested models?
Software versions
Python version : 3.12.0 | packaged by conda-forge | (main, Oct 3 2023, 08:26:13) [MSC v.1935 64 bit (AMD64)]
IPython version : 8.16.1
Tornado version : 6.3.3
Bokeh version : 3.3.0
BokehJS static path : C:\Users\XXX\miniconda3\envs\myenv312\Lib\site-packages\bokeh\server\static
node.js version : (not installed)
npm version : (not installed)
Operating system : Windows-10-10.0.19045-SP0
Browser name and version
Chrome Version 120.0.6099.71 (Offizieller Build) (64-Bit)
Jupyter notebook / Jupyter Lab version
No response
Expected behavior
In the following code, I change the source of a plot renderer in a callback.
For performance reasons (which don’t play a role in this minimal example), I first remove the plot from the layout, apply the change and then put the plot back to the layout.
This works fine, but as expected I get a blinking which I would like to avoid, so I use
curdoc().hold()
-curdoc().unhold()
.I would then expect the display to update after
curdoc().unhold()
, in my example the plot should go to 5000.Observed behavior
After
curdoc().unhold()
, the update is not shown.Also, I get a JavaScript console warning
reference already known 'p1002'
, P1002 being the id of the plot.Example code
Stack traceback or browser console output
For more information about why I remove the plot from the layout, see:
https://discourse.bokeh.org/t/layout-wont-update-after-curdoc-unhold/11109
Browser console output:
Screenshots
No response
The text was updated successfully, but these errors were encountered: