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

Hover not working if set before applying linked selections #4750

Closed
MarcSkovMadsen opened this issue Dec 13, 2020 · 2 comments · Fixed by #4756
Closed

Hover not working if set before applying linked selections #4750

MarcSkovMadsen opened this issue Dec 13, 2020 · 2 comments · Fixed by #4756
Assignees

Comments

@MarcSkovMadsen
Copy link
Collaborator

HoloViews: 1.14.0, bokeh: 2.2.3, 0.10.2

I'm trying to create an app for awesome-panel.org showcasing linked brushing but have difficulties getting hover to work.

Here is my example

hover_not_working

import holoviews as hv
import panel as pn
from holoviews import opts
from plotly.data import iris

hv.extension("bokeh")
pn.config.sizing_mode="stretch_width"

IRIS_DATASET = iris()

def _get_linked_plots():
    dataset = hv.Dataset(IRIS_DATASET)

    scatter = hv.Scatter(dataset, kdims=["sepal_length"], vdims=["sepal_width"]).opts(tools=["hover"], size=10)
    hist = hv.operation.histogram(dataset, dimension="petal_width", normed=False).opts(
        tools=["hover"]
    )

    # pylint: disable=no-value-for-parameter
    selection_linker = hv.selection.link_selections.instance()
    scatter = selection_linker(scatter)
    hist = selection_linker(hist)

    scatter=pn.pane.HoloViews(scatter, sizing_mode="stretch_both")
    hist=pn.pane.HoloViews(hist, sizing_mode="stretch_both")

    return pn.Column(scatter, hist, height=600)

_get_linked_plots().servable()
@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Dec 13, 2020

Additional Context: Works if you hover opts after linking plots.

I can see that it works if I set the tools opts after then plots have been linked. See below. I spent a long time figuring this out. It's confusing and frustrating as some opts like color and active_tools work if you set them before setting the linked selections. And it's not documented anywhere (I believe). So your guessing here.

hover_working_but_blurring

import holoviews as hv
import panel as pn
from holoviews import opts
from plotly.data import iris

hv.extension("bokeh")
pn.config.sizing_mode="stretch_width"

IRIS_DATASET = iris()

def _get_linked_plots():
    dataset = hv.Dataset(IRIS_DATASET)

    scatter = hv.Scatter(dataset, kdims=["sepal_length"], vdims=["sepal_width"]).opts(size=10)
    hist = hv.operation.histogram(dataset, dimension="petal_width", normed=False)

    # pylint: disable=no-value-for-parameter
    selection_linker = hv.selection.link_selections.instance()
    scatter = selection_linker(scatter).opts(opts.Scatter(tools=["hover"]))
    hist = selection_linker(hist).opts(opts.Histogram(tools=["hover"]))

    scatter=pn.pane.HoloViews(scatter, sizing_mode="stretch_both")
    hist=pn.pane.HoloViews(hist, sizing_mode="stretch_both")

    return pn.Column(scatter, hist, height=600)

_get_linked_plots().servable()

@jbednar
Copy link
Member

jbednar commented Dec 14, 2020

I agree that's confusing; I would have expected the options for the new object created by selection_linker to inherit the options from the original object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants