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

Add group and label to hover tooltip if provided by user #6125

Closed
wants to merge 9 commits into from
11 changes: 11 additions & 0 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,16 @@ def _hover_opts(self, element):
dims += element.dimensions()
return list(util.unique_iterator(dims)), {}

def _group_label(self, element):
droumis marked this conversation as resolved.
Show resolved Hide resolved
# return group and label if present
group_label = []
# group is the element type by default (e.g. Curve)
if hasattr(element, 'group') and element.group != type(element).__name__:
droumis marked this conversation as resolved.
Show resolved Hide resolved
group_label.append(('Group', element.group))
if hasattr(element, 'label') and element.label:
group_label.append(('Label', element.label))
return group_label

def _init_tools(self, element, callbacks=None):
"""
Processes the list of tools to be supplied to the plot.
Expand All @@ -295,6 +305,7 @@ def _init_tools(self, element, callbacks=None):
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]
tooltips += self._group_label(element)
droumis marked this conversation as resolved.
Show resolved Hide resolved
if not tooltips: tooltips = None

callbacks = callbacks+self.callbacks
Expand Down