Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Error : Width of undefined for Plotly.Plots.resize

hello,

After updating to latest plotly JS version, I have started seeing below error in console log
Uncaught TypeError: Cannot read property ‘width’ of undefined

After unit test I found that error is for function plots.resize.

The way I am calling resize function from my app is

Plotly.Plots.resize(“myDiv”).then(function () {

});

My Bad, some error in my function itself. Fixed it

Glad to hear that you find the error by urself.
btw: I think it makes a different if you call the resize function in that way:
Plotly.Plots.resize("myDiv");
or in that way:
Plotly.Plots.resize(document.getElementById("myDiv"));

At the first variant I get this error and the resizing of my chart don’t works: TypeError: Cannot read property ‘getComputedStyle’ of null(…

I write that because I see you use it in a similar way and maybe something other have the same error and problem and can think about that:-)

I would say first check if your DOM is ready. Check whether document.getElementById(“myDiv”) is loaded and not null or not undefined.