Skip to content

Commit 3c1aeba

Browse files
authored
Merge pull request #5865 from AllenDowney/mimerenderer-update-display
Redraw a figure in JupyterLab when its output is updated
2 parents bcc6863 + 078a6ec commit 3c1aeba

6 files changed

Lines changed: 15 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
88
- Add support for converting matplotlib reference lines (`axhline`, `axvline`, and horizontal/vertical `axline`) as well as axes-coordinate lines into Plotly layout shapes in `mpl_to_plotly`, including support for date axes [[#5719](https://github.com/plotly/plotly.py/pull/5719)], with thanks to @robertoffmoura for the contribution!
99

1010
### Fixed
11+
- Fix figures in JupyterLab not redrawing when their output is updated with `update_display_data` (for example `DisplayHandle.update`), which also kept animations in other kernels on their first frame [[#5865](https://github.com/plotly/plotly.py/pull/5865)], with thanks to @AllenDowney for the contribution!
1112
- Fix `mpl_to_plotly` tick marker mirroring, axis positioning, and trace visibility for twinned and overlaid subplots (such as `twinx` and `twiny`) [[#5310](https://github.com/plotly/plotly.py/pull/5310)], with thanks to @robertoffmoura for the contribution!
1213
- Fix `mpl_to_plotly` losing matplotlib axis line colors by exporting the color of each axis's displayed spine to the plotly x and y axis `linecolor` [[#5311](https://github.com/plotly/plotly.py/pull/5311)], with thanks to @robertoffmoura for the contribution!
1314
- Fix concurrent first access to lazily initialized graph object properties, which could raise `ValueError("Invalid value")` [[#5691](https://github.com/plotly/plotly.py/pull/5691)], with thanks to @hb1915 for the contribution!

‎js/lib/mimeExtension.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎js/src/mimeExtension.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,16 @@ export class RenderedPlotly extends Widget implements IRenderMime.IRenderer {
5454
*/
5555
renderModel(model: IRenderMime.IMimeModel): Promise<void> {
5656
if (this.hasGraphElement()) {
57-
// We already have a graph, don't overwrite it
58-
return Promise.resolve();
57+
// We already have a graph. Redraw it only if the figure has changed,
58+
// as it does when a kernel sends update_display_data. (createGraph
59+
// stores a PNG of the figure in the model, which calls renderModel
60+
// again with the same figure.)
61+
const previous = this._model?.data[this._mimeType];
62+
if (JSON.stringify(previous) === JSON.stringify(model.data[this._mimeType])) {
63+
return Promise.resolve();
64+
}
65+
this._model = model;
66+
return this.createGraph(model);
5967
}
6068

6169
// Save off reference to model so that we can regenerate the plot later

‎plotly/labextension/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"outputDir": "../plotly/labextension",
3434
"webpackConfig": "./webpack.config.js",
3535
"_build": {
36-
"load": "static/remoteEntry.1dda3c8f6e5cd2a3.js",
36+
"load": "static/remoteEntry.954b872b457cd897.js",
3737
"mimeExtension": "./mimeExtension"
3838
}
3939
}

plotly/labextension/static/0.03957c7088ad5ed0.js renamed to plotly/labextension/static/0.d6f08baae2d5090c.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plotly/labextension/static/remoteEntry.1dda3c8f6e5cd2a3.js renamed to plotly/labextension/static/remoteEntry.954b872b457cd897.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)