Skip to content

Commit 51de36c

Browse files
committed
Use DOM el attributes to find specified height/width, closes #1553
1 parent 6f151a7 commit 51de36c

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

Diff for: inst/htmlwidgets/plotly.js

+4-11
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ HTMLWidgets.widget({
88
},
99

1010
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;
1415
Plotly.relayout(el.id, {width: width, height: height});
1516
}
1617
},
@@ -153,17 +154,9 @@ HTMLWidgets.widget({
153154

154155
var plot = Plotly.plot(graphDiv, x);
155156
instance.plotly = true;
156-
instance.autosize = x.layout.autosize || true;
157-
instance.width = x.layout.width;
158-
instance.height = x.layout.height;
159157

160158
} else {
161159

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-
167160
// this is essentially equivalent to Plotly.newPlot(), but avoids creating
168161
// a new webgl context
169162
// https://github.com/plotly/plotly.js/blob/2b24f9def901831e61282076cf3f835598d56f0e/src/plot_api/plot_api.js#L531-L532

0 commit comments

Comments
 (0)