Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update custom HoverTool
  • Loading branch information
philippjfr committed Mar 4, 2020
1 parent 83490d7 commit 1121d53
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions holoviews/plotting/bokeh/element.py
Expand Up @@ -260,13 +260,19 @@ def _init_tools(self, element, callbacks=[]):
self.handles['hover'] = hover
return copied_tools


def _update_hover(self, element):
tooltips, hover_opts = self._hover_opts(element)
tooltips = [(ttp.pprint_label, '@{%s}' % util.dimension_sanitizer(ttp.name))
if isinstance(ttp, Dimension) else ttp for ttp in tooltips]
self.handles['hover'].tooltips = tooltips

tool = self.handles['hover']
if 'hv_created' in tool.tags:
tooltips, hover_opts = self._hover_opts(element)
tooltips = [(ttp.pprint_label, '@{%s}' % util.dimension_sanitizer(ttp.name))
if isinstance(ttp, Dimension) else ttp for ttp in tooltips]
tool.tooltips = tooltips
else:
plot_opts = element.opts.get('plot', 'bokeh')
new_hover = [t for t in plot_opts.kwargs.get('tools', [])
if isinstance(t, tools.HoverTool)]
if new_hover:
tool.tooltips = new_hover[0].tooltips

def _get_hover_data(self, data, element, dimensions=None):
"""
Expand Down Expand Up @@ -1390,7 +1396,7 @@ def update_frame(self, key, ranges=None, plot=None, element=None):
self._update_plot(key, plot, style_element)
self._set_active_tools(plot)

if 'hover' in self.handles and 'hv_created' in self.handles['hover'].tags:
if 'hover' in self.handles:
self._update_hover(element)

self._update_glyphs(element, ranges, self.style[self.cyclic_index])
Expand Down

0 comments on commit 1121d53

Please sign in to comment.