Skip to content

Commit

Permalink
Add hover_tooltips, hover_formatters, hover_mode (#1385)
Browse files Browse the repository at this point in the history
* Add hover_tooltips

* address comments
  • Loading branch information
ahuang11 authored Aug 7, 2024
1 parent dbd62bf commit d173da8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/user_guide/Customization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@
" hover_cols (default=[]): list or str\n",
" Additional columns to add to the hover tool or 'all' which will\n",
" includes all columns (including indexes if use_index is True).\n",
" hover_tooltips list[str] or list[tuple]:\n",
" A list of dimensions to be displayed in the hover tooltip. See\n",
" [HoloViews docs](https://holoviews.org/user_guide/Plotting_with_Bokeh.html#hover-tools)\n",
" or [Bokeh docs](https://docs.bokeh.org/en/latest/docs/user_guide/interaction/tools.html#hovertool)\n",
" for more info on structuring.\n",
" hover_formatters:\n",
" A dict of formatting options for the hover tooltip.\n",
" hover_mode (default='mouse'):\n",
" The hover mode determines how the hover tool is activated;\n",
" select from 'mouse', 'vline', or 'hline'.\n",
" invert (default=False): boolean\n",
" Swaps x- and y-axis\n",
" frame_width/frame_height: int\n",
Expand Down
15 changes: 15 additions & 0 deletions hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ class HoloViewsConverter:
hover_cols (default=[]): list or str
Additional columns to add to the hover tool or 'all' which will
includes all columns (including indexes if use_index is True).
hover_tooltips list[str] or list[tuple]:
A list of dimensions to be displayed in the hover tooltip.
hover_formatters:
A dict of formatting options for the hover tooltip.
hover_mode (default='mouse'):
The hover mode determines how the hover tool is activated.
invert (default=False): boolean
Swaps x- and y-axis
frame_width/frame_height: int
Expand Down Expand Up @@ -555,6 +561,9 @@ def __init__(
logy=None,
loglog=None,
hover=None,
hover_tooltips=None,
hover_formatters=None,
hover_mode=None,
subplots=False,
label=None,
invert=False,
Expand Down Expand Up @@ -829,6 +838,12 @@ def __init__(
else:
tools.append('hover')
plot_opts['tools'] = tools
if hover_tooltips:
plot_opts['hover_tooltips'] = hover_tooltips
if hover_formatters:
plot_opts['hover_formatters'] = hover_formatters
if hover_mode:
plot_opts['hover_mode'] = hover_mode

if self.crs and global_extent:
plot_opts['global_extent'] = global_extent
Expand Down

0 comments on commit d173da8

Please sign in to comment.