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

Add frames to Graph #540

Merged
merged 1 commit into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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