Responsive plotly.js was working, now it is not

@alexpetralia Thanks for writing in.

Your code is not missing anything, but rather has too many conflicting things.

Setting window.resize multiple times does not add as many on-resize handlers, but instead it overrides them, keeping only the last handler set active. In your case the last window.onresize statement resizes the blue line graph, which does behave responsively as intended.

To add multiple handlers to the same event, you’ll have to use to addEventListener method instead. For example,

window.addEventListener('resize', function() { Plotly.Plots.resize('blue_line'); });
window.addEventListener('resize', function() { Plotly.Plots.resize('red_line'); });

// ... and so on
4 Likes