File tree 1 file changed +6
-8
lines changed
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ HTMLWidgets.widget({
17
17
18
18
renderValue : function ( el , x , instance ) {
19
19
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 ) ) ;
25
+
20
26
/*
21
27
/ 'inform the world' about highlighting options this is so other
22
28
/ crosstalk libraries have a chance to respond to special settings
@@ -153,17 +159,9 @@ HTMLWidgets.widget({
153
159
154
160
var plot = Plotly . plot ( graphDiv , x ) ;
155
161
instance . plotly = true ;
156
- instance . autosize = x . layout . autosize || true ;
157
- instance . width = x . layout . width ;
158
- instance . height = x . layout . height ;
159
162
160
163
} else {
161
164
162
- // new x data could contain a new height/width...
163
- // attach to instance so that resize logic knows about the new size
164
- instance . width = x . layout . width || instance . width ;
165
- instance . height = x . layout . height || instance . height ;
166
-
167
165
// this is essentially equivalent to Plotly.newPlot(), but avoids creating
168
166
// a new webgl context
169
167
// https://github.com/plotly/plotly.js/blob/2b24f9def901831e61282076cf3f835598d56f0e/src/plot_api/plot_api.js#L531-L532
You can’t perform that action at this time.
0 commit comments