* Render Plotly into this widget's node.
(model: IRenderMime.IMimeModel)
| 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 |
nothing calls this directly
no test coverage detected