holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.67k stars 399 forks source link

Mechanism to create custom tool in toolbar #6319

Open ahuang11 opened 2 weeks ago

ahuang11 commented 2 weeks ago

In https://discourse.holoviz.org/t/custom-bokeh-toolbar-icon/7411 @droumis shared how to create a custom bokeh tool and add it to the current plot, which blew me away.

Having this functionality built into HoloViews can cleanup the dashboards that just require only a Panel toggle widget.

After, we can utilize it to additionally implement a draggable popup that can be toggled by a tool in the toolbar.

image

Example implementation:

tabler_icon_name = "crop-portrait"
popup_tool = CustomAction(
    icon=tabler_icon_name,
    description="Toggle Popup",
    callback=CustomJS(
        args={"popup": popup},
        code="""
        export default ({popup}) => {
            popup.visible = !popup.visible;
        }""",
    )
)
plot.opts(tools=[popup_tool])
droumis commented 2 weeks ago

Nice! For the record, I was inspired by how @hoxbro made a scalebar icon

droumis commented 2 weeks ago

+1 for popup draggability though... I haven't yet found a way to get that working with my example in discourse