Skip to content

Commit ecd4e9c

Browse files
Graph plot code refactoring.
1 parent 24e5acc commit ecd4e9c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

components/dash-core-components/src/fragments/Graph.react.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ class PlotlyGraph extends Component {
149149
figure = props._dashprivate_transformFigure(figure, gd);
150150
config = props._dashprivate_transformConfig(config, gd);
151151

152+
const figureClone = {
153+
data: figure.data,
154+
layout: this.getLayout(figure.layout, responsive),
155+
frames: figure.frames,
156+
config: this.getConfig(config, responsive),
157+
};
158+
152159
if (
153160
animate &&
154161
this._hasPlotted &&
@@ -159,22 +166,16 @@ class PlotlyGraph extends Component {
159166
if (figure.frames) {
160167
return Plotly.deleteFrames(gd)
161168
.then(() => Plotly.addFrames(gd, figure.frames))
162-
.then(() => Plotly.animate(gd, figure, animation_options));
169+
.then(() =>
170+
Plotly.animate(gd, figureClone, animation_options)
171+
);
163172
}
164-
return Plotly.animate(gd, figure, animation_options);
173+
return Plotly.animate(gd, figureClone, animation_options);
165174
}
166175

167-
const configClone = this.getConfig(config, responsive);
168-
const layoutClone = this.getLayout(figure.layout, responsive);
169-
170176
gd.classList.add('dash-graph--pending');
171177

172-
return Plotly.react(gd, {
173-
data: figure.data,
174-
layout: layoutClone,
175-
frames: figure.frames,
176-
config: configClone,
177-
}).then(() => {
178+
return Plotly.react(gd, figureClone).then(() => {
178179
const gd = this.gd.current;
179180

180181
// double-check gd hasn't been unmounted

0 commit comments

Comments
 (0)