Skip to content

Commit

Permalink
Adds Bokeh 3.5 enhancements to RangeToolLink (#6341)
Browse files Browse the repository at this point in the history
  • Loading branch information
droumis authored Aug 8, 2024
1 parent 6e9c4cb commit 59d81fa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
19 changes: 18 additions & 1 deletion holoviews/plotting/bokeh/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
VertexTableLink,
)
from ..plot import GenericElementPlot, GenericOverlayPlot
from .util import bokeh34
from .util import bokeh34, bokeh35


class LinkCallback:
Expand Down Expand Up @@ -182,6 +182,23 @@ def __init__(self, root_model, link, source_plot, target_plot):
ax.reset_end = end

tool = RangeTool(**axes)

if bokeh35:
use_handles = getattr(link, 'use_handles', True)
start_gesture = getattr(link, 'start_gesture', 'tap')
inverted = getattr(link, 'inverted', True)

tool.overlay.use_handles = use_handles
tool.start_gesture = start_gesture
tool.overlay.inverted = inverted

if use_handles:
tool.overlay.handles.all.hover_fill_color = "grey"
tool.overlay.handles.all.hover_fill_alpha = 0.25
tool.overlay.handles.all.hover_line_alpha = 0
tool.overlay.handles.all.fill_alpha = 0.1
tool.overlay.handles.all.line_alpha = 0.25

source_plot.state.add_tools(tool)
if toolbars:
toolbars[0].tools.append(tool)
Expand Down
11 changes: 10 additions & 1 deletion holoviews/plotting/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,17 @@ class RangeToolLink(Link):
intervalsy = param.Tuple(default=None, length=2, doc="""
(min, max) intervals for the y-axis""")

_requires_target = True
use_handles = param.Boolean(default=True, doc="""
Whether to display handles. Only available from Bokeh 3.5 onwards.""")

start_gesture = param.Selector(default='tap', objects=['pan', 'tap', 'none'],
doc="Gesture to start a range selection. Only available from Bokeh 3.5 onwards.")

inverted = param.Boolean(default=True, doc="""
Whether to invert the highlighting of the range selection.
Only available from Bokeh 3.5 onwards.""")

_requires_target = True

class DataLink(Link):
"""
Expand Down
1 change: 1 addition & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ plotly = ">=4.0"

[feature.py39.dependencies]
python = "3.9.*"
panel = "1.4.*"

[feature.py310.dependencies]
python = "3.10.*"
Expand Down

0 comments on commit 59d81fa

Please sign in to comment.