Skip to content

Commit ecb0c95

Browse files
committed
Fix for GH 158.
After computing the png image, the `model.setData` call was treating plotly's traces array (`data`) as if it were the bundle's `data` property (`model.data`). This was causing a malformed bundle to be saved in the notebook, and causing only the image/png form to be restored on notebook load.
1 parent 0f5b28a commit ecb0c95

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/plotly-extension/src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ export class RenderedPlotly extends Widget implements IRenderMime.IRenderer {
6262
height: this.node.offsetHeight
6363
}).then((url: string) => {
6464
const imageData = url.split(',')[1];
65-
model.setData({ data: { ...data, 'image/png': imageData } });
65+
if (model.data['image/png'] !== imageData) {
66+
model.setData({
67+
data: { ...model.data, 'image/png': imageData }
68+
});
69+
}
6670
});
6771
});
6872
}
@@ -73,7 +77,9 @@ export class RenderedPlotly extends Widget implements IRenderMime.IRenderer {
7377
height: this.node.offsetHeight
7478
}).then((url: string) => {
7579
const imageData = url.split(',')[1];
76-
model.setData({ data: { ...data, 'image/png': imageData } });
80+
if (model.data['image/png'] !== imageData) {
81+
model.setData({ data: { ...model.data, 'image/png': imageData } });
82+
}
7783
});
7884
});
7985
}

0 commit comments

Comments
 (0)