Skip to content

Commit 932e6af

Browse files
committed
Add auto-resizing of figures in JupyterLab when no width/heigh explicitly set
1 parent 6b889eb commit 932e6af

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

js/src/Figure.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,10 +793,22 @@ var FigureView = widgets.DOMWidgetView.extend({
793793
*/
794794
processPhosphorMessage: function(msg) {
795795
FigureView.__super__.processPhosphorMessage.apply(this, arguments);
796+
var that = this;
796797
switch (msg.type) {
797798
case 'after-attach':
798799
this.perform_render();
799800
break;
801+
case 'resize':
802+
var layout = this.model.get('_layout');
803+
if (_.isNil(layout) ||
804+
(_.isNil(layout.width) && _.isNil(layout.height))) {
805+
Plotly.Plots.resize(this.el).then(function(){
806+
var layout_edit_id = that.model.get(
807+
"_last_layout_edit_id");
808+
that._sendLayoutDelta(layout_edit_id);
809+
});
810+
}
811+
break
800812
}
801813
},
802814

0 commit comments

Comments
 (0)