Uncaught TypeError: Cannot read property '_guiEditing' of undefined

Hi there
I have a weird bug that doesn’t seem to affect anything but happens when I resize a plot. Just thought I should let you know.
Uncaught TypeError: Cannot read property ‘_guiEditing’ of undefined
at Z (plotly-latest.min.js:7)
at Object.q [as relayout] (plotly-latest.min.js:7)

switch (a pp.params.stations.length) { //this is how many separate plots I have on screen)
case 1:
graphHeight = 600;
break;
case 2:
graphHeight = 300;
break;
case 3:
graphHeight = 200;
break;
case 4:
graphHeight = 150;
break;
};
jQuery(’.graphDiv’).each(function (index, div) {
if (jQuery(div).has(‘div.plotly’)) {
jQuery(div).removeClass(‘h600’).removeClass(‘h300’).removeClass(‘h200’).removeClass(‘h150’).addClass(‘h’ + graphHeight);
Plotly.relayout(jQuery(div).attr(‘id’), {
height: graphHeight
});
}
});

Thanks for the report!

This would help us immensely. Thanks!

I’ve tried using the unminified version before and get an error:_Uncaught SyntaxError: Invalid or unexpected token_and then _Uncaught ReferenceError: Plotly is not defined_

This one really is too complicated to put in a codepen, sorry.

The error I get with using the unminified version is on line 19440. “Invalid or unexpected token”.
Somewhere after π on
var ε = 1e-6, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π;

See https://github.com/plotly/plotly.js#non-ascii-characters

You might need to add charset="utf-8" to your script tag.

Ah, I missed that! Thanks that works.
So here’s the error in the unminified version:
Uncaught TypeError: Cannot read property ‘_guiEditing’ of undefined
at _relayout (plotly.js:106278)
at Object.relayout (plotly.js:106176)
at HTMLDivElement. (app.js:1055)
at Function.each (jquery-3.3.1.min.js:2)
at w.fn.init.each (jquery-3.3.1.min.js:2)
at Object.app.resizePlots (app.js:1052)
at Object.app.drawGraphs (app.js:1034)
at NewClass. (app.js:560)
at NewClass.fire (Events.js:190)
at NewClass._fireDOMEvent (Map.js:1386)

Looks like you’re calling Plotly.relayout before Plotly.newPlot. Could that be the case?

1 Like

Ah! You’ve found it, I forgot to wait for the Plotly promise to fulfil. Thank you so much.

This error occurs in Chrome Browser when you read a property or call a method on an undefined object . Uncaught TypeError: Cannot read property of undefined error is probably easiest to understand from the perspective of undefined, since undefined is not considered an object type at all (but its own undefined type instead), and properties can only belong to objects within JavaScript. There are a few variations of this error depending on the property you are trying to access. Sometimes instead of undefined it will say null.

@gnasher Could you please share your solution here? I’m running into the same error thank you very much.

This worked for me!

I wrote an if statement to check if objects got loaded or not:


const first_box = document.getElementById('first-figure-box');
const third_box = document.getElementById('third-figure-box');
        
if (Object.keys(first_box).includes('data') && Object.keys(third_box).includes('data')) {
     toggle_markers(toggle) // relayouts are in func
}

Thanks for the help guys! kudos!