# \`legend\_groupclick = "toggleitem"\` doesn't seem to work in PlotlyJS

**URL:** <https://discourse.julialang.org/t/legend-groupclick-toggleitem-doesnt-seem-to-work-in-plotlyjs/76851>\
**Category:** Visualization\
**Tags:** plotlyjs\
**Created:** [February 21, 2022, 3:37pm UTC](https://discourse.julialang.org/t/legend-groupclick-toggleitem-doesnt-seem-to-work-in-plotlyjs/76851 "2022-02-21T15:37:30Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [June 6, 2023, 9:13pm UTC](https://discourse.julialang.org/t/legend-groupclick-toggleitem-doesnt-seem-to-work-in-plotlyjs/76851/5 "2023-06-06T21:13:21Z")

</div>

The package [PlotlyLight.jl](https://github.com/JuliaComputing/PlotlyLight.jl) knows about the feature: `groupclick`.  
Here is my sample code:

```julia
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)

```

---

_[View the full topic](https://discourse.julialang.org/t/legend-groupclick-toggleitem-doesnt-seem-to-work-in-plotlyjs/76851)._
