File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ HTMLWidgets.widget({
1717
1818 renderValue : function ( el , x , instance ) {
1919
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+
2026 /*
2127 / 'inform the world' about highlighting options this is so other
2228 / crosstalk libraries have a chance to respond to special settings
@@ -153,17 +159,9 @@ HTMLWidgets.widget({
153159
154160 var plot = Plotly . plot ( graphDiv , x ) ;
155161 instance . plotly = true ;
156- instance . autosize = x . layout . autosize || true ;
157- instance . width = x . layout . width ;
158- instance . height = x . layout . height ;
159162
160163 } else {
161164
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-
167165 // this is essentially equivalent to Plotly.newPlot(), but avoids creating
168166 // a new webgl context
169167 // 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