@@ -8,9 +8,10 @@ HTMLWidgets.widget({
8
8
} ,
9
9
10
10
resize : function ( el , width , height , instance ) {
11
- if ( instance . autosize ) {
12
- var width = instance . width || width ;
13
- var height = instance . height || height ;
11
+ if ( el . layout . autosize || true ) {
12
+ // User specified height/width overrides htmlwidgets height/width
13
+ var width = el . layout . width || width ;
14
+ var height = el . layout . height || height ;
14
15
Plotly . relayout ( el . id , { width : width , height : height } ) ;
15
16
}
16
17
} ,
@@ -153,17 +154,9 @@ HTMLWidgets.widget({
153
154
154
155
var plot = Plotly . plot ( graphDiv , x ) ;
155
156
instance . plotly = true ;
156
- instance . autosize = x . layout . autosize || true ;
157
- instance . width = x . layout . width ;
158
- instance . height = x . layout . height ;
159
157
160
158
} else {
161
159
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
160
// this is essentially equivalent to Plotly.newPlot(), but avoids creating
168
161
// a new webgl context
169
162
// https://github.com/plotly/plotly.js/blob/2b24f9def901831e61282076cf3f835598d56f0e/src/plot_api/plot_api.js#L531-L532
0 commit comments