Skip to content

Commit

Permalink
enh: Add active toggle to scalebar icon (#6473)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Mar 4, 2025
1 parent 2465ad1 commit 53e9049
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
BOKEH_GE_3_4_0,
BOKEH_GE_3_5_0,
BOKEH_GE_3_6_0,
BOKEH_GE_3_7_0,
TOOL_TYPES,
cds_column_replace,
compute_layout_properties,
Expand Down Expand Up @@ -2491,6 +2492,7 @@ def _draw_scalebar(self, *, plot, renderer):
</g>
</svg>"""
encoded_icon = base64.b64encode(dedent(ruler_icon).encode()).decode('ascii')
active_kwargs = {"active_callback": "auto", "active": True} if BOKEH_GE_3_7_0 else {}
scalebar_tool = CustomAction(
icon=f"data:image/svg+xml;base64,{encoded_icon}",
description="Toggle ScaleBar",
Expand All @@ -2502,7 +2504,8 @@ def _draw_scalebar(self, *, plot, renderer):
scale_bars[i].visible = !scale_bars[i].visible
}
}""",
)
),
**active_kwargs,
)
plot.toolbar.tools.append(scalebar_tool)

Expand Down
1 change: 1 addition & 0 deletions holoviews/plotting/bokeh/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
BOKEH_GE_3_4_0 = BOKEH_VERSION >= (3, 4, 0)
BOKEH_GE_3_5_0 = BOKEH_VERSION >= (3, 5, 0)
BOKEH_GE_3_6_0 = BOKEH_VERSION >= (3, 6, 0)
BOKEH_GE_3_7_0 = BOKEH_VERSION >= (3, 7, 0)

TOOL_TYPES = {
'pan': tools.PanTool,
Expand Down

0 comments on commit 53e9049

Please sign in to comment.