beliaf
October 25, 2023, 4:09pm
1
Good morning, I have 2 figures
First for graph
graph = figure(
x_range=Range1d(data.first().created, data.last().created),
x_axis_type='datetime',
y_range=Range1d(1, 1000),
)
and second for RangeTool
# Range Graph
range_figure = figure(
x_axis_type='datetime',
y_axis_type=None,
tools='',
toolbar_location=None,
height=50,
background_fill_color='#ffffff',
)
range_tool = RangeTool(x_range=composite_graph.x_range)
range_tool.overlay.fill_color = 'navy'
range_tool.overlay.fill_alpha = 0.2
range_figure.line(
x=[reading.created for reading in readings],
y=[reading.reading['ORP'] for reading in readings]
)
range_figure.xaxis.visible = False
range_figure.add_tools(range_tool)
I try to put them on TabPanel like children
...
TabPanel(
title='Graph',
child=layout(
children=[
column(
children=[header_div],
sizing_mode='stretch_width'
),
graph,
range_figure
],
sizing_mode='stretch_width'
),
),
...
Everything is created perfectly, but after I try to embed it in React I have an error:
models must be owned by only a single document
Error shows only during rerender of the component only after 2-nd render.
When for e.i I remove one of the figures everything is working.
Bryan
October 25, 2023, 5:17pm
2
Most likely this, which will be fixed in upcoming 3.3.1
opened 09:22PM - 17 Oct 23 UTC
type: bug
tag: regression
tag: component: bokehjs
### Software versions
Python version : 3.11.4 | packaged by Anaconda, Inc… . | (main, Jul 5 2023, 13:47:18) [MSC v.1916 64 bit (AMD64)]
IPython version : 8.12.2
Tornado version : 6.3.2
Bokeh version : 3.3.0
BokehJS static path : C:\Users\xxx\AppData\Local\anaconda3\envs\IoT\Lib\site-packages\bokeh\server\static
node.js version : v18.16.0
npm version : 9.5.1
Operating system : Windows-10-10.0.22621-SP0
### Browser name and version
Firefox 115.3.1esr
### Jupyter notebook / Jupyter Lab version
JupyterLab 3.6.3
### Expected behavior
I try to use the RangeTool in a Jupyter Notebook and I expect to see two plots, where one plot shows the RangeTool.
### Observed behavior
I see no output in the notebook. In the browser's console I see "Uncaught (in promise) Error: models must be owned by only a single document". When I only show the ```p``` plot, it shows correctly. Also, if I uncomment ```select.add_tools(range_tool)``` it shows two plots (although I cannot reproduce that in the moment).
I already discussed the issue with Bryan [here](https://discourse.bokeh.org/t/rangetool-not-working-in-jupyter-notebook/10944/5).
### Example code
```Python
from bokeh.io import output_notebook, show, output_file
from bokeh.plotting import figure
from bokeh.models import ColumnDataSource, DatetimeTickFormatter, RangeTool, Range1d
from bokeh.layouts import column
output_notebook()
timestamps = [1, 2, 3, 4, 5]
values = [10, 20, 30, 40, 50]
dummy_data = {'timestamp': timestamps, 'value': values}
source = ColumnDataSource(dummy_data)
p = figure(title="test",
x_axis_type="datetime", x_range=(dummy_data['timestamp'][1], dummy_data['timestamp'][-1]),
y_axis_label='Flow rate [l/s]',
sizing_mode="stretch_width", height=350,
tools="xpan")
p.line(x="timestamp", y="value", source=source, line_width=2)
# format the x-axis tick labels as datetime strings
p.xaxis.formatter = DatetimeTickFormatter(hours="%d %B %Y", days="%Y%m%d", months="%d %B %Y", years="%d %B %Y")
# range tool
select = figure(title="Drag the middle and edges of the selection box to change the range above",
x_axis_type="datetime",
y_axis_type=None, y_range=p.y_range,
sizing_mode="stretch_width", height=150,
tools="") # tools="", toolbar_location=None, background_fill_color="#efefef"
range_tool = RangeTool(x_range=p.x_range)
range_tool.overlay.fill_color = "navy"
range_tool.overlay.fill_alpha = 0.2
select.line(x="timestamp", y="value", source=source)
select.ygrid.grid_line_color = None
select.add_tools(range_tool)
# show the results
#show(p)
show(column(p, select))
```
### Stack traceback or browser console output
Bokeh: BokehJS not loaded, scheduling load and callback at
Date Tue Oct 17 2023 23:13:59 GMT+0200 (Mitteleuropäische Sommerzeit)
[jlab_core.14859e35e858759bad31.js:201:13](http://localhost:8892/static/lab/jlab_core.14859e35e858759bad31.js?v=14859e35e858759bad31%20line%202%20%3E%20eval)
Bokeh: injecting script tag for BokehJS library: https://cdn.bokeh.org/bokeh/release/bokeh-3.3.0.min.js [jlab_core.14859e35e858759bad31.js:235:15](http://localhost:8892/static/lab/jlab_core.14859e35e858759bad31.js?v=14859e35e858759bad31%20line%202%20%3E%20eval)
Bokeh: injecting script tag for BokehJS library: https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.3.0.min.js [jlab_core.14859e35e858759bad31.js:235:15](http://localhost:8892/static/lab/jlab_core.14859e35e858759bad31.js?v=14859e35e858759bad31%20line%202%20%3E%20eval)
Bokeh: injecting script tag for BokehJS library: https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.3.0.min.js [jlab_core.14859e35e858759bad31.js:235:15](http://localhost:8892/static/lab/jlab_core.14859e35e858759bad31.js?v=14859e35e858759bad31%20line%202%20%3E%20eval)
Bokeh: injecting script tag for BokehJS library: https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.3.0.min.js [jlab_core.14859e35e858759bad31.js:235:15](http://localhost:8892/static/lab/jlab_core.14859e35e858759bad31.js?v=14859e35e858759bad31%20line%202%20%3E%20eval)
Bokeh: injecting script tag for BokehJS library: https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.3.0.min.js [jlab_core.14859e35e858759bad31.js:235:15](http://localhost:8892/static/lab/jlab_core.14859e35e858759bad31.js?v=14859e35e858759bad31%20line%202%20%3E%20eval)
Bokeh: all BokehJS libraries/stylesheets loaded [jlab_core.14859e35e858759bad31.js:207:17](http://localhost:8892/static/lab/jlab_core.14859e35e858759bad31.js?v=14859e35e858759bad31%20line%202%20%3E%20eval)
Bokeh: BokehJS plotting callback run at
Date Tue Oct 17 2023 23:14:01 GMT+0200 (Mitteleuropäische Sommerzeit)
[jlab_core.14859e35e858759bad31.js:279:15](http://localhost:8892/static/lab/jlab_core.14859e35e858759bad31.js?v=14859e35e858759bad31%20line%202%20%3E%20eval)
[bokeh] setting log level to: 'info' [bokeh-3.3.0.min.js:184:1311](https://cdn.bokeh.org/bokeh/release/bokeh-3.3.0.min.js)
Bokeh: all callbacks have finished [jlab_core.14859e35e858759bad31.js:185:13](http://localhost:8892/static/lab/jlab_core.14859e35e858759bad31.js?v=14859e35e858759bad31%20line%202%20%3E%20eval)
Uncaught (in promise) Error: models must be owned by only a single document
attach_document bokeh-3.3.0.min.js:179
_recompute_all_models bokeh-3.3.0.min.js:165
_invalidate_all_models bokeh-3.3.0.min.js:165
setv bokeh-3.3.0.min.js:179
update bokeh-3.3.0.min.js:410
update_overlay_from_ranges bokeh-3.3.0.min.js:684
initialize bokeh-3.3.0.min.js:684
a bokeh-3.3.0.min.js:224
build_views bokeh-3.3.0.min.js:224
build_tool_views bokeh-3.3.0.min.js:595
lazy_initialize bokeh-3.3.0.min.js:595
a bokeh-3.3.0.min.js:224
build_views bokeh-3.3.0.min.js:224
build_child_views bokeh-3.3.0.min.js:560
lazy_initialize bokeh-3.3.0.min.js:560
a bokeh-3.3.0.min.js:224
build_view bokeh-3.3.0.min.js:224
u bokeh-3.3.0.min.js:218
u bokeh-3.3.0.min.js:218
add_document_standalone bokeh-3.3.0.min.js:218
embed_items_notebook bokeh-3.3.0.min.js:231
embed_document jlab_core.14859e35e858759bad31.js:5
<anonymous> jlab_core.14859e35e858759bad31.js:8
<anonymous> jlab_core.14859e35e858759bad31.js:24
evalInContext index.js:12
n index.js:21
render index.js:43
renderModel widgets.js:45
createRenderedMimetype widget.js:501
createOutputItem widget.js:481
_insertOutput widget.js:441
onModelChanged widget.js:244
g index.es6.js:510
c index.es6.js:465
emit index.es6.js:121
_onListChanged model.js:231
g index.es6.js:510
c index.es6.js:465
emit index.es6.js:121
push observablelist.js:139
_add model.js:207
add model.js:128
_onIOPub widget.js:93
_handleIOPub future.js:230
handleMsg future.js:199
_handleMessage default.js:1225
_msgChain default.js:162
promise callback*19883/b/this._onWSMessage default.js:159
### Screenshots
_No response_
(Ignore the “Jupyter notebook” part of the OP title, the issue is deeper than that)
1 Like