Skip to content

Commit

Permalink
Update lookup data in _update_hover
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Oct 25, 2024
1 parent 8f71e46 commit 2775f06
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion holoviews/plotting/bokeh/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def _hover_opts(self, element):
def _update_hover(self, element):
tool = self.handles['hover']
if isinstance(tool.tooltips, Div):
self._hover_data = element.data
return
super()._update_hover(element)

Expand All @@ -72,6 +73,7 @@ def _init_tools(self, element, callbacks=None):
if hover is None or not (XArrayInterface.applies(data) and "has_selector" in data.attrs):
return tools

self._hover_data = data
coords, vars = tuple(data.coords), tuple(data.data_vars)
dims = (*coords, *vars)

Expand Down Expand Up @@ -101,7 +103,7 @@ def _init_tools(self, element, callbacks=None):
)

def on_change(attr, old, new):
data_sel = data.sel(**dict(zip(coords, new)), method="nearest").to_dict()
data_sel = self._hover_data.sel(**dict(zip(coords, new)), method="nearest").to_dict()
# TODO: When ValueOf support formatter remove the rounding
# https://github.com/bokeh/bokeh/issues/14123
data_coords = {dim: round(data_sel['coords'][dim]['data'], 3) for dim in coords}
Expand Down

0 comments on commit 2775f06

Please sign in to comment.