✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

How to toggle trace visibility across multiple graphs

I know that I can set the visibility of the trace on the chart by the visible property but this only affects the chart that I clicked on. On a page with multiple charts using similarly named traces, how can I toggle the visibility of all the similarly named traces at the same time?

Here was my attempt but this didn’t have any affect and only toggled the chart I clicked.

        let updatedChartingData = [...this.state.chartingData];
        for (let chart of updatedData) {
            for (let i = 0; i < chart.tickerEntities.length; i++) {
                let trace = chart.tickerEntities[i];
                if (trace.name === trace_name) {
                    if (!trace.visible) {
                        trace.visible = "legendonly";
                    }
                    else if ((typeof trace.visible) === "string") {
                        trace.visible = true;
                    }
                    else {
                        trace.visible = "legendonly";                         
                    }

                }
            }
        }