Skip to content

Commit

Permalink
Update custom HoverTool (#4266)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Mar 5, 2020
1 parent bcea69c commit d02b805
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
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 d02b805

Please sign in to comment.