@@ -14,9 +14,9 @@ HTMLWidgets.widget({
1414 } ,
1515
1616 resize : function ( el , width , height , instance ) {
17- var width = instance . width || width ;
18- var height = instance . height || height ;
19- Plotly . relayout ( el . id , { width : width , height : height } ) ;
17+ if ( instance . autosize ) {
18+ Plotly . relayout ( el . id , { width : width , height : height } ) ;
19+ }
2020 } ,
2121
2222 renderValue : function ( el , x , instance ) {
@@ -30,16 +30,14 @@ HTMLWidgets.widget({
3030 }
3131
3232 var graphDiv = document . getElementById ( el . id ) ;
33- var layout = x . layout || { } ;
3433
3534 // if no plot exists yet, create one with a particular configuration
3635 if ( ! instance . plotly ) {
37- var plot = Plotly . plot ( graphDiv , x . data , layout , x . config ) ;
36+ var plot = Plotly . plot ( graphDiv , x . data , x . layout , x . config ) ;
3837 instance . plotly = true ;
39- instance . height = layout . height ;
40- instance . width = layout . width ;
38+ instance . autosize = x . layout . autosize ;
4139 } else {
42- var plot = Plotly . newPlot ( graphDiv , x . data , layout ) ;
40+ var plot = Plotly . newPlot ( graphDiv , x . data , x . layout ) ;
4341 }
4442
4543 sendEventData = function ( eventType ) {
0 commit comments