Skip to content

Commit 26f0e7a

Browse files
Fixed graph animate frames.
1 parent 0f1b299 commit 26f0e7a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ class PlotlyGraph extends Component {
146146
const {animate, animation_options, responsive} = props;
147147

148148
const gd = this.gd.current;
149-
150149
figure = props._dashprivate_transformFigure(figure, gd);
151150
config = props._dashprivate_transformConfig(config, gd);
152151

@@ -155,7 +154,19 @@ class PlotlyGraph extends Component {
155154
this._hasPlotted &&
156155
figure.data.length === gd.data.length
157156
) {
158-
return Plotly.animate(gd, figure, animation_options);
157+
// in case we've have figure frames,
158+
// we need to recreate frames before animation
159+
let result;
160+
if (figure.frames) {
161+
result = Plotly.deleteFrames(gd).then(() => {
162+
return Plotly.addFrames(gd, figure.frames).then(() => {
163+
return Plotly.animate(gd, figure, animation_options);
164+
});
165+
});
166+
} else {
167+
result = Plotly.animate(gd, figure, animation_options);
168+
}
169+
return result;
159170
}
160171

161172
const configClone = this.getConfig(config, responsive);

0 commit comments

Comments
 (0)