Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Uncaught container is not an object" after layout is sent to newPlot #3350

Closed
poldz123 opened this issue Dec 19, 2018 · 4 comments
Closed

Comments

@poldz123
Copy link

poldz123 commented Dec 19, 2018

When editing the layout object after it was sent it to Plotly.newPlot, it causes an error log Uncaught container is not an object.

Seems only for non-objects that causes it:

var layout = {
  title: "title",
  margin: {
      l: 30,
      r: 50,
      t: 30,
      b: 10
    }
};

Plotly.newPlot('contourDiv', data, layout, {displayModeBar: false});
console.log(layout)
layout.margin = {} -> It works
layout.title = "edit title" -> Causes the error
Plotly.update('contourDiv', data, layout)

Before version 1.43.0 the above code works.

https://codepen.io/poldz123/pen/pqNBzj?editors=0010

@etpinard
Copy link
Contributor

This must be a side-effect of #3276 - where we deprecated layout.title and replaced it with layout.title.text.

More generally, if you (1) newPlot (2) mutate data/layout (3) update the graph, you should be using Plotly.react at step (3) instead of Plotly.update. Passing whole data/layout objects to update will always result in the slowest possible update path - whereas react will attempt to find the faster update path possible.

Oh well, we should still try to fix this thing.

@etpinard
Copy link
Contributor

also note that

var layout = {
  title: "title",
  margin: {l: 30, r: 50, t: 30, b: 10}
};

var data = [{
  y: [1, 2, 1]
}]

Plotly.newPlot('graph', data, layout, {displayModeBar: false});
console.log(layout)
layout.margin = {}
layout.title.text = "edit title"
Plotly.update('graph', data, layout)

works as expected.

@etpinard
Copy link
Contributor

as well as:

var layout = {
  title: "title",
  margin: {l: 30, r: 50, t: 30, b: 10}
};

var data = [{
  y: [1, 2, 1]
}]

Plotly.newPlot('graph', data, layout, {displayModeBar: false});
console.log(layout);
layout.margin = {};
layout.title = "edit title";
Plotly.react('graph', data, layout)

@poldz123
Copy link
Author

poldz123 commented Dec 21, 2018

@etpinard Ended up with the react instead, not seeing any changes on performance though. Well, it does not matter. Closing this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants