Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group or hide hover tools in Bokeh toolbar #6252

Open
droumis opened this issue May 29, 2024 · 7 comments
Open

Group or hide hover tools in Bokeh toolbar #6252

droumis opened this issue May 29, 2024 · 7 comments
Labels
TRIAGE Needs triaging

Comments

@droumis
Copy link
Member

droumis commented May 29, 2024

Is your feature request related to a problem? Please describe.

Too many hover tools when overlaying many elements with custom hover.

Describe the solution you'd like

Group or hide the hover tooltips

Additional context

Code
import numpy as np
import pandas as pd
from datetime import datetime, timedelta

import holoviews as hv; hv.extension('bokeh')
import panel as pn; pn.extension()

amp_dim = hv.Dimension("amplitude", unit="µV")
time_dim = hv.Dimension("time", unit="ms")

n_channels = 10
n_seconds = 5
total_samples = 256*n_seconds
start_datetime = datetime(2024, 1, 1)
time = np.array([start_datetime + timedelta(seconds=t) for t in np.linspace(0, n_seconds, total_samples)])

data = np.random.randn(n_channels, total_samples).cumsum(axis=1)
channels = [f"EEG {i}" for i in range(n_channels)]

df = pd.DataFrame(data.T, index=time, columns=channels)
df.index.name = 'time'

hover_tooltips=[
    ("type", "$group"),
    ("channel", "$label"),
    ("time", '@time{%H:%M:%S.%3N}'),
    ("amplitude"),
]

curves = {}
for channel_name, channel_data in df.items():
    ds = hv.Dataset((channel_data.index, channel_data, channel), [time_dim, amp_dim, "channel"])
    curve = hv.Curve(ds, time_dim, [amp_dim, "channel"], label=channel_name, group='EEG')
    curve.opts(color="black", line_width=1, subcoordinate_y=True, subcoordinate_scale=3,
              hover_tooltips = hover_tooltips)
    curves[channel_name] = curve

curves_overlay = hv.Overlay(curves, kdims="channel").opts(padding=0, aspect=2, responsive=True,show_legend=False)

curves_overlay

image

@droumis droumis added the TRIAGE Needs triaging label May 29, 2024
@droumis
Copy link
Member Author

droumis commented May 29, 2024

@mattpap , this could be solved with the ability to group tools which is sounds like you are working on.

@mattpap
Copy link

mattpap commented May 29, 2024

Yes. The relevant bokeh issue is bokeh/bokeh#5497 (a very old one).

@droumis
Copy link
Member Author

droumis commented May 29, 2024

observation: if I create a custom bokeh HoverTool, and pass that in like .opts(tools=[HoverTool()] then the hover tools are combined in the toolbar.

@droumis
Copy link
Member Author

droumis commented Jun 3, 2024

observation: adding a plot with many hover tool icons into a layout container seems to group the tools...

image image

@droumis
Copy link
Member Author

droumis commented Jun 7, 2024

even just hv.Layout((overlay, hv.Empty())

@philippjfr
Copy link
Member

Yeah, we should probably run the group_tools function even on a singular plot.

@droumis
Copy link
Member Author

droumis commented Jun 18, 2024

e.g. as we do here for a Layout toolbar

@droumis droumis moved this to Todo in CZI R5 neuro Jun 23, 2024
@droumis droumis moved this from Todo to Dropped in CZI R5 neuro Jul 2, 2024
@droumis droumis moved this from Dropped to idea in CZI R5 neuro Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TRIAGE Needs triaging
Projects
None yet
Development

No branches or pull requests

3 participants