Repository: holoviz/holoviews
Pull request #6282 (2024-06-12 11:53:33)

 Fix hover label 
Fixes  #6280

![image](https://github.com/holoviz/holoviews/assets/19758978/dd3e10f0-091a-4a29-85f5-072296087f22)


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/holoviz/holoviews/pull/6282?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=holoviz) Report
Attention: Patch coverage is `75.00000%` with `2 lines` in your changes missing coverage. Please review.
> Project coverage is 88.50%. Comparing base [(`8c99659`)](https://app.codecov.io/gh/holoviz/holoviews/commit/8c99659d07d6b0d98ed6fc936b00d926fa6d51c9?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=holoviz) to head [(`4cf7e66`)](https://app.codecov.io/gh/holoviz/holoviews/commit/4cf7e66414074566e31b46173ce219f526632264?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=holoviz).

| [Files](https://app.codecov.io/gh/holoviz/holoviews/pull/6282?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=holoviz) | Patch % | Lines |
|---|---|---|
| [holoviews/plotting/bokeh/element.py](https://app.codecov.io/gh/holoviz/holoviews/pull/6282?src=pr&el=tree&filepath=holoviews%2Fplotting%2Fbokeh%2Felement.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=holoviz#diff-aG9sb3ZpZXdzL3Bsb3R0aW5nL2Jva2VoL2VsZW1lbnQucHk=) | 75.00% | [2 Missing :warning: ](https://app.codecov.io/gh/holoviz/holoviews/pull/6282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=holoviz) |

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main    #6282      +/-   ##
==========================================
- Coverage   88.54%   88.50%   -0.04%     
==========================================
  Files         323      323              
  Lines       67977    67977              
==========================================
- Hits        60190    60163      -27     
- Misses       7787     7814      +27     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/holoviz/holoviews/pull/6282?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=holoviz).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=holoviz).

droumis: fix confirmed!

Patch:
diff --git a/holoviews/plotting/bokeh/element.py b/holoviews/plotting/bokeh/element.py
index f5fea8f2b..659e4bd52 100644
--- a/holoviews/plotting/bokeh/element.py
+++ b/holoviews/plotting/bokeh/element.py
@@ -421,7 +421,7 @@ class ElementPlot(BokehPlot, GenericElementPlot):
         tooltips, hover_opts = self._hover_opts(element)
 
         dim_aliases = {
-            f"{dim.label} ({dim.unit})" if dim.unit else dim.label: dim.name
+            f"{dim.label} ({dim.unit})" if dim.unit else dim.label: dim.label
             for dim in element.kdims + element.vdims
         }
 
@@ -430,10 +430,10 @@ class ElementPlot(BokehPlot, GenericElementPlot):
         units_dict = {}
         for ttp in tooltips:
             if isinstance(ttp, tuple):
-                name = ttp[0]
+                label = ttp[0]
                 tuple_ = (ttp[0], ttp[1])
             elif isinstance(ttp, Dimension):
-                name = ttp.name
+                label = ttp.label
                 # three brackets means replacing variable,
                 # and then wrapping in brackets, like @{air}
                 unit = f" ({ttp.unit})" if ttp.unit else ""
@@ -441,19 +441,19 @@ class ElementPlot(BokehPlot, GenericElementPlot):
                     ttp.pprint_label,
                     f"@{{{util.dimension_sanitizer(ttp.name)}}}"
                 )
-                units_dict[name] = unit
+                units_dict[label] = unit
             elif isinstance(ttp, str):
-                name = ttp
+                label = ttp
                 # three brackets means replacing variable,
                 # and then wrapping in brackets, like @{air}
-                tuple_ = (ttp.name, f"@{{{util.dimension_sanitizer(ttp)}}}")
+                tuple_ = (ttp, f"@{{{util.dimension_sanitizer(ttp)}}}")
 
-            if name in dim_aliases:
-                name = dim_aliases[name]
+            if label in dim_aliases:
+                label = dim_aliases[label]
 
             # key is the vanilla data column/dimension name
             # value should always be a tuple (label, value)
-            tooltips_dict[name] = tuple_
+            tooltips_dict[label] = tuple_
 
         # subset the tooltips to only the ones user wants
         if self.hover_tooltips:
@@ -943,11 +943,11 @@ class ElementPlot(BokehPlot, GenericElementPlot):
                     if axis_label and axis in self.labelled:
                         properties[f'{axis}_axis_label'] = axis_label
                     locs = {'left': 'left', 'right': 'right'} if axis == 'y' else {'bottom': 'below', 'top': 'above'}
-                    if axis_position is None:
+                    if axis_position in (None, False):
                         axis_props[axis]['visible'] = False
                     axis_props[axis].update(fontsize)
                     for loc, pos in locs.items():
-                        if axis_position and loc in axis_position:
+                        if isinstance(axis_position, str) and loc in axis_position:
                             properties[f'{axis}_axis_location'] = pos
 
         if not self.show_frame:


Test patch:
diff --git a/holoviews/tests/plotting/bokeh/test_curveplot.py b/holoviews/tests/plotting/bokeh/test_curveplot.py
index 0ef1b5b8e..042d72fb8 100644
--- a/holoviews/tests/plotting/bokeh/test_curveplot.py
+++ b/holoviews/tests/plotting/bokeh/test_curveplot.py
@@ -5,7 +5,7 @@ import pandas as pd
 import pytest
 from bokeh.models import FactorRange, FixedTicker
 
-from holoviews.core import DynamicMap, HoloMap, NdOverlay
+from holoviews.core import Dimension, DynamicMap, HoloMap, NdOverlay
 from holoviews.core.options import AbbreviatedException, Cycle, Palette
 from holoviews.element import Curve
 from holoviews.plotting.bokeh.callbacks import Callback, PointerXCallback
@@ -109,6 +109,18 @@ class TestCurvePlot(TestBokehPlot):
         obj = obj.opts(opts)
         self._test_hover_info(obj, [('Test', '@{Test}'), ('x', '@{x}'), ('y', '@{y}')], 'nearest')
 
+    def test_curve_hover_dimension(self):
+        obj = Curve(
+            range(10), Dimension('name', label='label')
+        ).opts(hover_tooltips=['label'])
+        self._test_hover_info(obj, [('label', '@{name}')], 'nearest')
+
+    def test_curve_hover_dimension_unit(self):
+        obj = Curve(
+            range(10), Dimension('name', label='label', unit='unit')
+        ).opts(hover_tooltips=['label'])
+        self._test_hover_info(obj, [('label (unit)', '@{name}')], 'nearest')
+
     def test_curve_categorical_xaxis(self):
         curve = Curve((['A', 'B', 'C'], [1,2,3]))
         plot = bokeh_renderer.get_plot(curve)
diff --git a/holoviews/tests/plotting/bokeh/test_elementplot.py b/holoviews/tests/plotting/bokeh/test_elementplot.py
index 7e3c02d9d..c465ac46b 100644
--- a/holoviews/tests/plotting/bokeh/test_elementplot.py
+++ b/holoviews/tests/plotting/bokeh/test_elementplot.py
@@ -111,6 +111,26 @@ class TestElementPlot(LoggingComparisonTestCase, TestBokehPlot):
         self.assertEqual(xaxis.major_tick_line_color, None)
         self.assertTrue(xaxis in plot.state.above)
 
+    def test_element_yaxis_true(self):
+        curve = Curve(range(10)).opts(yaxis=True)
+        plot = bokeh_renderer.get_plot(curve)
+        yaxis = plot.handles['yaxis']
+        assert yaxis in plot.state.left
+
+    def test_element_yaxis_false(self):
+        curve = Curve(range(10)).opts(yaxis=False)
+        plot = bokeh_renderer.get_plot(curve)
+        yaxis = plot.handles['yaxis']
+        assert yaxis in plot.state.left
+        assert not yaxis.visible
+
+    def test_element_yaxis_none(self):
+        curve = Curve(range(10)).opts(yaxis=None)
+        plot = bokeh_renderer.get_plot(curve)
+        yaxis = plot.handles['yaxis']
+        assert yaxis in plot.state.left
+        assert not yaxis.visible
+
     def test_element_yaxis_right(self):
         curve = Curve(range(10)).opts(yaxis='right')
         plot = bokeh_renderer.get_plot(curve)