Black Lives Matter. Please consider donating to Black Girls Code today.

Can I use Plotly.relayout without a plotly_relayout event?

I have multiple graphs and I want to sync the range of all the graphs. I use plotly_relayout event on the graphs but if I use ploly.relayout function to change the range of the other graph the function will be recall for the other graph and it will make an infinite loop.
So is there a way to disable the events ? or a parameter for ploly.relayout to don’t call the callback function for plotly_relayout event ?

1 Like

here’s a workaround:

I’m using Angular and each Angular graph component subscribes to a service which emits to all graph components if one of them changes.

I simply can’t fix that same infinite loop bug no matter what I try. Been fighting it for a couple of days now. @etienne’s workaround sadly doesn’t work for me.

Weird part is, it only happens when I double-click to zoom out. Otherwise it works and I can keep the zoom synchronized without starting the infinite loop. Ideas?

Hi all,

I would benefit for such a feature a lot. Workarounds are hard to maintain and introduce bugs.
I think what exposed here is a general requirement, since in relayout handlers often there is a need to relayout other charts as well, and every call to relayout triggers another relayout event, with the risk of running into an infinite loop.

Is there a better approach to this?

Use update () instead of Relayout () like this

Plotly.update(myPlot, {}, updates)

that way you update the layout without calling the Relayout () event