@@ -17,6 +17,14 @@ HTMLWidgets.widget({
17
17
18
18
renderValue : function ( el , x , instance ) {
19
19
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 ;
27
+
20
28
/*
21
29
/ 'inform the world' about highlighting options this is so other
22
30
/ crosstalk libraries have a chance to respond to special settings
@@ -153,17 +161,9 @@ HTMLWidgets.widget({
153
161
154
162
var plot = Plotly . plot ( graphDiv , x ) ;
155
163
instance . plotly = true ;
156
- instance . autosize = x . layout . autosize || true ;
157
- instance . width = x . layout . width ;
158
- instance . height = x . layout . height ;
159
164
160
165
} else {
161
166
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
167
// this is essentially equivalent to Plotly.newPlot(), but avoids creating
168
168
// a new webgl context
169
169
// https://github.com/plotly/plotly.js/blob/2b24f9def901831e61282076cf3f835598d56f0e/src/plot_api/plot_api.js#L531-L532
0 commit comments