Repository: bokeh/bokeh

Issue:
[BUG] $name not being passed to hovertool for image plots
If you try to use $name in tooltips for image plots, then you just get the javascript error message:
"Uncaught Error: Unknown special variable '$name'"

An example would be taking your example at: https://docs.bokeh.org/en/latest/docs/user_guide/tools.html#image-hover and adding ('name', '$name') to the TOOLTIP variable.

I believe this can be fixed changing this line of code:
https://github.com/bokeh/bokeh/blob/5b1befb97ca2c4b3dc0f0d18690b8668d6481c96/bokehjs/src/lib/models/tools/inspectors/hover_tool.ts#L269

to include:
name: renderer_view.model.name

However I don't know enough about the internals of bokeh to know if this is correct - modifying identical looking code in bokeh.js did appear to fix it for me.

Thanks,
Sam


Discussion:
@samr85 Offhand, that seems like the correct solution, can you submit a PR with the change?
So I've tried doing this, but tooltips seem to be broken in the version I pulled from the repository - image tooltips no longer display at all, and HTML seems to have been disabled in line tooltips.  I can make a pull request for my change, but until image tooltips are working again there is no way for me to see if it is working.
@samr85 you are going to have to be more specific with the exact actual steps you are taking. Both image hover and custom html tooltip are working correcting:

* In the latest full release docs:

    https://docs.bokeh.org/en/latest/docs/user_guide/tools.html#image-hover

    https://docs.bokeh.org/en/lastest/docs/user_guide/tools.html#custom-tooltip


* In last weeks "dev build" docs:

    https://docs.bokeh.org/en/dev/docs/user_guide/tools.html#image-hover

    https://docs.bokeh.org/en/dev/docs/user_guide/tools.html#custom-tooltip


Edit: However image hover is broken on HEAD of `branch-2.2` so evidently a very recent regression. I've filed an issue here: https://github.com/bokeh/bokeh/issues/10324 Custom HTML template still works fine there, at least on that scatter, so more info/a reproducer is still needed for that. 
Thanks, yes that was what I was trying on.  I didn't mean a custom HTML template, sorry I should have been more descriptive.
Having a tooltip of:
```
HoverTool(
    tooltips=[
        ( 'hellotitle',   '<div style="color: red">hello</div>'),
    ])
```

Previously displayed hello in red.  In the head of 2.2 it now displays the html text.
@samr85 I'm afraid I think that was some accidental and unintentional behavior that was never documented or maintained under test. AFAIK usage of HTML is only supported (and intended to be supported) in custom templates. cc @philippjfr @mattpap for comment, though, in case I missed some addition. 
I'm sure about this precise usage but the `HoverTool` definitely should support custom tooltips like in this example in the docs: https://docs.bokeh.org/en/latest/docs/user_guide/tools.html#custom-tooltip
Thanks both - I'll switch to using the full custom tooltips then, rather than using undocumented features in the basic one :)
> https://docs.bokeh.org/en/latest/docs/user_guide/tools.html#custom-tooltip

This still works, because there's `{safe}` involved. Remove it and it won't allow HTML content anymore. This is a regression after PR #10237, where I made a stricter distinction between raw strings and strings containing HTML content. I will fix this together with #10324.



Resolving patch:
diff --git a/sphinx/source/docs/user_guide/examples/tools_hover_tooltips_image.py b/sphinx/source/docs/user_guide/examples/tools_hover_tooltips_image.py
--- a/sphinx/source/docs/user_guide/examples/tools_hover_tooltips_image.py
+++ b/sphinx/source/docs/user_guide/examples/tools_hover_tooltips_image.py
@@ -17,6 +17,7 @@
             dh=[10,  10, 25])
 
 TOOLTIPS = [
+    ('name', "$name"),
     ('index', "$index"),
     ('pattern', '@pattern'),
     ("x", "$x"),
@@ -25,7 +26,7 @@
     ('squared', '@squared')
 ]
 
-p = figure( x_range=(0, 35), y_range=(0, 35), tools='hover,wheel_zoom', tooltips=TOOLTIPS)
-p.image(source=data, image='image', x='x', y='y', dw='dw', dh='dh', palette="Inferno256")
+p = figure(x_range=(0, 35), y_range=(0, 35), tools='hover,wheel_zoom', tooltips=TOOLTIPS)
+p.image(source=data, image='image', x='x', y='y', dw='dw', dh='dh', palette="Inferno256", name="Image Glyph")
 
 show(p)


Test patch: