@@ -17,6 +17,14 @@ HTMLWidgets.widget({
1717
1818 renderValue : function ( el , x , instance ) {
1919
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+
2028 /*
2129 / 'inform the world' about highlighting options this is so other
2230 / crosstalk libraries have a chance to respond to special settings
@@ -153,17 +161,9 @@ HTMLWidgets.widget({
153161
154162 var plot = Plotly . plot ( graphDiv , x ) ;
155163 instance . plotly = true ;
156- instance . autosize = x . layout . autosize || true ;
157- instance . width = x . layout . width ;
158- instance . height = x . layout . height ;
159164
160165 } else {
161166
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-
167167 // this is essentially equivalent to Plotly.newPlot(), but avoids creating
168168 // a new webgl context
169169 // https://github.com/plotly/plotly.js/blob/2b24f9def901831e61282076cf3f835598d56f0e/src/plot_api/plot_api.js#L531-L532
0 commit comments