(props)
| 166 | } |
| 167 | |
| 168 | plot(props) { |
| 169 | let {figure, config} = props; |
| 170 | const {animate, animation_options, responsive, mathjax} = props; |
| 171 | |
| 172 | const gd = this.gd.current; |
| 173 | figure = props._dashprivate_transformFigure(figure, gd); |
| 174 | config = props._dashprivate_transformConfig(config, gd); |
| 175 | |
| 176 | const configClone = this.getConfig(config, responsive); |
| 177 | // add typesetMath | not exposed to the dash API |
| 178 | configClone.typesetMath = mathjax; |
| 179 | |
| 180 | const figureClone = { |
| 181 | data: figure?.data, |
| 182 | layout: this.getLayout(figure?.layout, responsive), |
| 183 | frames: figure?.frames, |
| 184 | config: configClone, |
| 185 | }; |
| 186 | |
| 187 | if ( |
| 188 | animate && |
| 189 | this._hasPlotted && |
| 190 | figure.data.length === gd.data.length |
| 191 | ) { |
| 192 | // in case we've have figure frames, |
| 193 | // we need to recreate frames before animation |
| 194 | if (figure.frames) { |
| 195 | return Plotly.deleteFrames(gd) |
| 196 | .then(() => Plotly.addFrames(gd, figure.frames)) |
| 197 | .then(() => |
| 198 | Plotly.animate(gd, figureClone, animation_options) |
| 199 | ); |
| 200 | } |
| 201 | return Plotly.animate(gd, figureClone, animation_options); |
| 202 | } |
| 203 | |
| 204 | gd.classList.add('dash-graph--pending'); |
| 205 | |
| 206 | return lazyLoadMathJax(mathjax) |
| 207 | .then(() => { |
| 208 | const gd = this.gd.current; |
| 209 | return gd && Plotly.react(gd, figureClone); |
| 210 | }) |
| 211 | .then(() => { |
| 212 | const gd = this.gd.current; |
| 213 | |
| 214 | // double-check gd hasn't been unmounted |
| 215 | if (!gd) { |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | gd.classList.remove('dash-graph--pending'); |
| 220 | |
| 221 | // in case we've made a new DOM element, transfer events |
| 222 | if (this._hasPlotted && gd !== this._prevGd) { |
| 223 | if (this._prevGd && this._prevGd.removeAllListeners) { |
| 224 | this._prevGd.removeAllListeners(); |
| 225 | Plotly.purge(this._prevGd); |
no test coverage detected