
I’m in the process of migrating a bokeh-based dashboard from 2.4.3 to 3.2.2. In one of my plots, I have implemented a method to embed some simple bokeh plots inside the tooltip of another plot and I did that by following the solution provided here: Bar plot inside Tooltip - #4 by Bryan
This solution worked perfectly fine in Bokeh 2.4 but I can’t make it work with the latest version of Bokeh. For reference, the code from the link above (slightly modified for V3.2.2) is:
import json
from bokeh.embed import json_item
from bokeh.models import ColumnDataSource, CustomJSHover, HoverTool
from bokeh.plotting import figure, show
source = ColumnDataSource(data=dict(x=[1, 4, 8], y=[2, 8, 5]))
p = figure()
p.circle('x', 'y', size=20, source=source)
p2 = figure(height=150, width=400, toolbar_location=None)
p2.hbar(y=[1, 2], right=[5, 10], height=0.8)
out = json.dumps(json_item(p2, "tooltip-plot"))
source.data['plot'] = [out, out, out]
code="""
Bokeh.embed.embed_item(JSON.parse(value))
return ""
"""
p.add_tools(HoverTool(
tooltips='<div id="tooltip-plot">@plot{custom}</div>',
formatters={ '@plot': CustomJSHover(code=code) }
))
show(p)
When I run this, I get the following error in my browser (which is the same as the error I get in my own code that used to work):
Uncaught (in promise) Error: Error rendering Bokeh model: could not find #tooltip-plot HTML tag
It looks like Bokeh.embed.embed_item is not able to find the HTML div with the given tag. Any help for how to resolve this is greatly appreciated. Thanks in advance and thanks for the awesome library!

