From 59d81faa44bbfe9f9c4d3752f585f23e5af6d59e Mon Sep 17 00:00:00 2001 From: Demetris Roumis Date: Thu, 8 Aug 2024 10:10:06 -0700 Subject: [PATCH] Adds Bokeh 3.5 enhancements to RangeToolLink (#6341) --- holoviews/plotting/bokeh/links.py | 19 ++++++++++++++++++- holoviews/plotting/links.py | 11 ++++++++++- pixi.toml | 1 + 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/holoviews/plotting/bokeh/links.py b/holoviews/plotting/bokeh/links.py index 5cf61d738a..36ac59b92e 100644 --- a/holoviews/plotting/bokeh/links.py +++ b/holoviews/plotting/bokeh/links.py @@ -13,7 +13,7 @@ VertexTableLink, ) from ..plot import GenericElementPlot, GenericOverlayPlot -from .util import bokeh34 +from .util import bokeh34, bokeh35 class LinkCallback: @@ -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) diff --git a/holoviews/plotting/links.py b/holoviews/plotting/links.py index 0d528c4a2e..25289f0200 100644 --- a/holoviews/plotting/links.py +++ b/holoviews/plotting/links.py @@ -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): """ diff --git a/pixi.toml b/pixi.toml index 56d0579808..b3aa914d7d 100644 --- a/pixi.toml +++ b/pixi.toml @@ -40,6 +40,7 @@ plotly = ">=4.0" [feature.py39.dependencies] python = "3.9.*" +panel = "1.4.*" [feature.py310.dependencies] python = "3.10.*"