Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update custom HoverTool #4266

Merged
merged 1 commit into from
Mar 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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