-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Software versions
Python version : 3.11.0 | packaged by conda-forge | (main, Jan 14 2023, 12:27:40) [GCC 11.3.0]
IPython version : 8.14.0
Tornado version : 6.3.3
Bokeh version : 3.5.0
BokehJS static path : /work/scratch/env/tonneas/.conda/envs/py311_test/lib/python3.11/site-packages/bokeh/server/static
node.js version : (not installed)
npm version : (not installed)
Operating system : Linux-4.18.0-477.27.1.el8_8.x86_64-x86_64-with-glibc2.28
Browser name and version
No response
Jupyter notebook / Jupyter Lab version
No response
Expected behavior
I have a custom HoverTool and CustomJSHover doing some actions on the hover content. I would like to format the hover, for example, introduce some html <br> tags when a string is too long. But I don't see how to use {safe} option in the HoverTool definition to escape those html tags and display line breaks instead.
Observed behavior
Example code
Here is my HoverTool code :
from bokeh.plotting import figure, show
from bokeh.models import HoverTool, CustomJSHover
from bokeh.io import output_notebook
output_notebook()
p = figure(x_range=(0, 3), y_range=(0, 3),)
p.scatter(x=[0, 1, 2], y=[0, 1, 2], size=30)
custom_code = """
var value;
return value + ' veryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy lonnnnnnnnnnnnnnnnnnnnnnnnnnnnnnng striiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiing'
"""
hovertool = HoverTool(
tooltips=[("xx", "@x{custom}")],
formatters={"@x": CustomJSHover(code=custom_code)},
)
p.add_tools(hovertool)
show(p)