Skip to content

Commit 9ec031d

Browse files
committed
Process Lumino messages with compatibility with Phosphor
See jupyter-widgets/ipywidgets/pull/3124 for resize change rationale
1 parent eb80f50 commit 9ec031d

File tree

1 file changed

+23
-9
lines changed
  • packages/javascript/jupyterlab-plotly/src

1 file changed

+23
-9
lines changed

packages/javascript/jupyterlab-plotly/src/Figure.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,10 @@ export class FigureModel extends DOMWidgetModel {
716716

717717
static serializers: ISerializers = {
718718
...DOMWidgetModel.serializers,
719-
_data: { deserialize: py2js_deserializer, serialize: js2py_serializer },
719+
_data: {
720+
deserialize: py2js_deserializer,
721+
serialize: js2py_serializer,
722+
},
720723
_layout: {
721724
deserialize: py2js_deserializer,
722725
serialize: js2py_serializer,
@@ -806,7 +809,7 @@ export class FigureView extends DOMWidgetView {
806809
viewID: string;
807810

808811
/**
809-
* The perform_render method is called by processPhosphorMessage
812+
* The perform_render method is called by processLuminoMessage
810813
* after the widget's DOM element has been attached to the notebook
811814
* output cell. This happens after the initialize of the
812815
* FigureModel, and it won't happen at all if the Python FigureWidget
@@ -900,10 +903,10 @@ export class FigureView extends DOMWidgetView {
900903
}
901904

902905
/**
903-
* Respond to phosphorjs events
906+
* Respond to Lumino events
904907
*/
905-
processPhosphorMessage(msg: any) {
906-
super.processPhosphorMessage.apply(this, arguments);
908+
_processLuminoMessage(msg: any, _super: any) {
909+
_super.apply(this, arguments);
907910
var that = this;
908911
switch (msg.type) {
909912
case "before-attach":
@@ -921,10 +924,6 @@ export class FigureView extends DOMWidgetView {
921924
xaxis: axisHidden,
922925
yaxis: axisHidden,
923926
});
924-
925-
window.addEventListener("resize", function () {
926-
that.autosizeFigure();
927-
});
928927
break;
929928
case "after-attach":
930929
// Rendering actual figure in the after-attach event allows
@@ -938,6 +937,21 @@ export class FigureView extends DOMWidgetView {
938937
}
939938
}
940939

940+
processPhosphorMessage(msg: any) {
941+
this._processLuminoMessage(msg, super["processPhosphorMessage"]);
942+
943+
var that = this;
944+
if (msg.type === "before-attach") {
945+
window.addEventListener("resize", function () {
946+
that.autosizeFigure();
947+
});
948+
}
949+
}
950+
951+
processLuminoMessage(msg: any) {
952+
this._processLuminoMessage(msg, super["processLuminoMessage"]);
953+
}
954+
941955
autosizeFigure() {
942956
var that = this;
943957
var layout = that.model.get("_layout");

0 commit comments

Comments
 (0)