MCPcopy Index your code
hub / github.com/plotly/plotly.py / renderModel

Method renderModel

js/src/mimeExtension.ts:55–74  ·  view source on GitHub ↗

* Render Plotly into this widget's node.

(model: IRenderMime.IMimeModel)

Source from the content-addressed store, hash-verified

53 * Render Plotly into this widget's node.
54 */
55 renderModel(model: IRenderMime.IMimeModel): Promise<void> {
56 if (this.hasGraphElement()) {
57 // We already have a graph, don't overwrite it
58 return Promise.resolve();
59 }
60
61 // Save off reference to model so that we can regenerate the plot later
62 this._model = model;
63
64 // Check for PNG data in mime bundle
65 const png_data = <string>model.data["image/png"];
66 if (png_data !== undefined && png_data !== null) {
67 // We have PNG data, use it
68 this.updateImage(png_data);
69 return Promise.resolve();
70 } else {
71 // Create a new graph
72 return this.createGraph(model);
73 }
74 }
75
76 private hasGraphElement() {
77 // Check for the presence of the .plot-container element that plotly.js

Callers

nothing calls this directly

Calls 4

hasGraphElementMethod · 0.95
updateImageMethod · 0.95
createGraphMethod · 0.95
resolveMethod · 0.45

Tested by

no test coverage detected