Plotly.relayout() giving error

I am using plotly for plotting my graphs . I am using the below code for resizing my plotly graph , when I resize my browser window.

  $(window).resize(function() {
   var divheight = $("#section").height();
   var divwidth = $("#section").width();

   var update = {
          width:divwidth,  // or any new width
          height:divheight // " "
        };

Plotly.relayout('section', update);

    }).resize()`

However I am getting the following error in the console when I try to run the code .

plotly-basic.js:17 Uncaught bad container

PS: I am using flask for backend and Javascript , HTML for displaying the plotly plots . I am new to plotly

Can someone please help me out :frowning:

Weird.

Is the Plotly.relayout call always executed after the initial Plotly.plot call?

In other words, I think you’re trying to relayout a graph that hasn’t been plotting yet.

1 Like

Thanks alot etienne :smiley: You were right :smiley: I was trying to relayout a graph that hasn’t been plotted yet. Thank alot :slight_smile: