Skip to content

Commit a0cd2f2

Browse files
committed
no need to be making deep copies
1 parent e07f80c commit a0cd2f2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

inst/htmlwidgets/plotly.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ HTMLWidgets.widget({
1717

1818
renderValue: function(el, x, instance) {
1919

20-
// Make a deep copy of user data that we need for the resize method
21-
// (Plotly.relayout() mutates the plot input object -- https://codepen.io/cpsievert/pen/WNeOrjj)
22-
instance.width = JSON.parse(JSON.stringify(x.layout.width || null));
23-
instance.height = JSON.parse(JSON.stringify(x.layout.height || null));
24-
instance.autosize = JSON.parse(JSON.stringify(x.layout.autosize || true));
20+
// Plotly.relayout() mutates the plot input object, so make sure to
21+
// keep a reference to the user-supplied width/height *before*
22+
// we call Plotly.plot();
23+
var lay = x.layout || {};
24+
instance.width = lay.width;
25+
instance.height = lay.height;
26+
instance.autosize = lay.autosize || true;
2527

2628
/*
2729
/ 'inform the world' about highlighting options this is so other

0 commit comments

Comments
 (0)