click_policy=hide is treated as "mute" for my chart. A bug?

I am trying to use the “click_policy=‘hide’” option, so the user can click the legend to hide certain datasets.

However, when I use the option, it seems to use “click_policy=‘mute’” (that is: fading out the data rather than hiding it).

Is this a bug? Or am I doing something wrong?

Here is a repro:

import hvplot.pandas
import holoviews as hv
hv.extension("bokeh")

from bokeh.sampledata.autompg import autompg_clean as df
print(df)

plot = df.hvplot(
    x='mpg',
    y='hp',
    kind='scatter',
    by=['origin'],
).opts(
    hv.opts.Overlay(legend_opts=dict(click_policy='hide'))
)

hvplot.save(plot, "chart.html")

The output of hvplot is not an Overlay but an NdOverlay. You should be able to just do this, though: df.hvplot(...).opts(legend_opts=dict(click_policy='hide'))

Ah, thank you!

I guess partly a victim of github#6047.

Weirdly, I had it inside the hvplot(…) args, and it wasn’t working in my real use-case, but does seem to work now. Must have been my error.

For anyone else who comes here, this is my summary:

plot = df.hvplot(
    # ... other args ...
    
    # OK
    #legend_opts=dict(click_policy='hide'),
).opts(
    # OK
    legend_opts=dict(click_policy='hide')
    # OK
    #hv.opts.NdOverlay(legend_opts=dict(click_policy='hide'))
    # Bad
    #hv.opts.Overlay(legend_opts=dict(click_policy='hide'))
)