Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 4153430

Browse files
Add frames to Graph (#540)
1 parent 4843ed1 commit 4153430

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## Unreleased
66

7+
### Added
8+
9+
- `figure` prop in `dcc.Graph` now accepts a `frames` key
10+
711
### Removed
812

913
- Removed unused `key` prop from `dcc.ConfirmDialog`

src/components/Graph.react.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,18 @@ class PlotlyGraph extends Component {
104104
) {
105105
return Plotly.animate(id, figure, animation_options);
106106
}
107-
return Plotly.react(id, figure.data, clone(figure.layout), config).then(
108-
() => {
109-
if (!this._hasPlotted) {
110-
this.bindEvents();
111-
Plotly.Plots.resize(document.getElementById(id));
112-
this._hasPlotted = true;
113-
}
107+
return Plotly.react(id, {
108+
data: figure.data,
109+
layout: clone(figure.layout),
110+
frames: figure.frames,
111+
config: config,
112+
}).then(() => {
113+
if (!this._hasPlotted) {
114+
this.bindEvents();
115+
Plotly.Plots.resize(document.getElementById(id));
116+
this._hasPlotted = true;
114117
}
115-
);
118+
});
116119
}
117120

118121
extend(props) {
@@ -327,13 +330,13 @@ const graphPropTypes = {
327330
/**
328331
* Plotly `figure` object. See schema:
329332
* https://plot.ly/javascript/reference
330-
* Only supports `data` array and `layout` object.
331-
* `config` is set separately by the `config` property,
332-
* and `frames` is not supported.
333+
*
334+
* `config` is set separately by the `config` property
333335
*/
334336
figure: PropTypes.exact({
335337
data: PropTypes.arrayOf(PropTypes.object),
336338
layout: PropTypes.object,
339+
frames: PropTypes.arrayOf(PropTypes.object),
337340
}),
338341

339342
/**
@@ -628,7 +631,7 @@ const graphDefaultProps = {
628631
relayoutData: null,
629632
extendData: null,
630633
restyleData: null,
631-
figure: {data: [], layout: {}},
634+
figure: {data: [], layout: {}, frames: []},
632635
animate: false,
633636
animation_options: {
634637
frame: {

0 commit comments

Comments
 (0)