The package PlotlyLight.jl knows about the feature: groupclick
.
Here is my sample code:
using PlotlyLight
# --- Docu: https://plotly.com/javascript/
# --- Change template
# PlotlyLight.Preset.Template.plotly_dark!()
# --- Make plot, first two traces at once in two legendgroups:
fig_obj = PlotlyLight.Plot()(
x = 1:20, y = cumsum(randn(20)), type="scatter", mode="lines+markers",
legendgroup = "A", legendgrouptitle = Dict("text" => "group_name A"),)(
x = 1:20, y = cumsum(randn(20)), type="scatter", mode="lines+markers",
legendgroup = "B", legendgrouptitle = Dict("text" => "group_name B"),);
# --- add new trace:
fig_obj()(
x = 1:20, y = cumsum(randn(20)), type="scatter", mode="lines+markers", legendgroup = "B", name = "new trace");
# ---
fig_obj.layout.legend.groupclick = "toggleitem"
display(fig_obj)