Skip to content

Commit 6b82823

Browse files
authored
Merge pull request jupyterlab#176 from gnestor/jupyterlab-5890
Use Plotly.react vs. Plotly.newPlot
2 parents d7ae542 + 57e9541 commit 6b82823

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

packages/plotly-extension/src/index.ts

+4-19
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,15 @@ export class RenderedPlotly extends Widget implements IRenderMime.IRenderer {
5151
| any
5252
| IPlotlySpec;
5353
// const metadata = model.metadata[this._mimeType] as any || {};
54-
return Plotly.newPlot(this.node, data, layout, config).then(plot => {
54+
return Plotly.react(this.node, data, layout, config).then(plot => {
55+
this.update();
5556
if (frames) {
56-
return Plotly.addFrames(this.node, frames).then(() => {
57+
Plotly.addFrames(this.node, frames).then(() => {
5758
Plotly.animate(this.node);
58-
this.update();
59-
if (this.node.offsetWidth > 0 && this.node.offsetHeight > 0) {
60-
return Plotly.toImage(plot, {
61-
format: 'png',
62-
width: this.node.offsetWidth,
63-
height: this.node.offsetHeight
64-
}).then((url: string) => {
65-
const imageData = url.split(',')[1];
66-
if (model.data['image/png'] !== imageData) {
67-
model.setData({
68-
data: { ...model.data, 'image/png': imageData }
69-
});
70-
}
71-
});
72-
}
7359
});
7460
}
75-
this.update();
7661
if (this.node.offsetWidth > 0 && this.node.offsetHeight > 0) {
77-
return Plotly.toImage(plot, {
62+
Plotly.toImage(plot, {
7863
format: 'png',
7964
width: this.node.offsetWidth,
8065
height: this.node.offsetHeight

0 commit comments

Comments
 (0)