Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Link plotly_legendclick between several charts


Would like to ask if someone knows a way to link the plotly_legendclick event between several independent plots (with independent, I mean there are not subplots).

An image

Basically I want to hide/show the same trace index in all charts, when I click on a legend element.

If I click “Sim 1” in a chart, the same trace has to be hidden/shown in the other charts.

Thank you!

Ok, just found how to make this…

	plotTarget.on('plotly_legendclick', function(ev){
		var isoTarget = document.getElementById("isotherm");
		var etcTarget = document.getElementById("etc");
		if (typeof[ev.curveNumber].visible ==="undefined"){[ev.curveNumber].visible='legendonly';[ev.curveNumber].visible='legendonly';[ev.curveNumber].visible='legendonly';
		else if (typeof[ev.curveNumber].visible !=="undefined"){[ev.curveNumber].visible=undefined;[ev.curveNumber].visible=undefined;[ev.curveNumber].visible=undefined;

		return false;