Skip to content

Commit

Permalink
Add frames to Graph (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaskruchten committed Apr 30, 2019
1 parent 4843ed1 commit 4153430
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Added

- `figure` prop in `dcc.Graph` now accepts a `frames` key

### Removed

- Removed unused `key` prop from `dcc.ConfirmDialog`
Expand Down
27 changes: 15 additions & 12 deletions src/components/Graph.react.js
Expand Up @@ -104,15 +104,18 @@ class PlotlyGraph extends Component {
) {
return Plotly.animate(id, figure, animation_options);
}
return Plotly.react(id, figure.data, clone(figure.layout), config).then(
() => {
if (!this._hasPlotted) {
this.bindEvents();
Plotly.Plots.resize(document.getElementById(id));
this._hasPlotted = true;
}
return Plotly.react(id, {
data: figure.data,
layout: clone(figure.layout),
frames: figure.frames,
config: config,
}).then(() => {
if (!this._hasPlotted) {
this.bindEvents();
Plotly.Plots.resize(document.getElementById(id));
this._hasPlotted = true;
}
);
});
}

extend(props) {
Expand Down Expand Up @@ -327,13 +330,13 @@ const graphPropTypes = {
/**
* Plotly `figure` object. See schema:
* https://plot.ly/javascript/reference
* Only supports `data` array and `layout` object.
* `config` is set separately by the `config` property,
* and `frames` is not supported.
*
* `config` is set separately by the `config` property
*/
figure: PropTypes.exact({
data: PropTypes.arrayOf(PropTypes.object),
layout: PropTypes.object,
frames: PropTypes.arrayOf(PropTypes.object),
}),

/**
Expand Down Expand Up @@ -628,7 +631,7 @@ const graphDefaultProps = {
relayoutData: null,
extendData: null,
restyleData: null,
figure: {data: [], layout: {}},
figure: {data: [], layout: {}, frames: []},
animate: false,
animation_options: {
frame: {
Expand Down

0 comments on commit 4153430

Please sign in to comment.