Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 44b2bd5

Browse files
authored
Merge pull request #126 from plotly/plot-refresh-fix
Update when figure changes regardless of revision
2 parents df8fb07 + 0108bbe commit 44b2bd5

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ In short, this means that simply adding data points to a trace in `data` or chan
123123
| `layout` | `Object` | `undefined` | layout object (see https://plot.ly/javascript/reference/#layout) |
124124
| `frames` | `Array` | `undefined` | list of frame objects (see https://plot.ly/javascript/reference/) |
125125
| `config` | `Object` | `undefined` | config object (see https://plot.ly/javascript/configuration-options/) |
126-
| `revision` | `Number` | `undefined` | When provided, causes the plot to update _only_when the revision is incremented. |
126+
| `revision` | `Number` | `undefined` | When provided, causes the plot to update when the revision is incremented. |
127127
| `onInitialized` | `Function(figure, graphDiv)` | `undefined` | Callback executed after plot is initialized. See below for parameter information. |
128128
| `onUpdate` | `Function(figure, graphDiv)` | `undefined` | Callback executed when when a plot is updated due to new data or layout, or when user interacts with a plot. See below for parameter information. |
129129
| `onPurge` | `Function(figure, graphDiv)` | `undefined` | Callback executed when component unmounts, before `Plotly.purge` strips the `graphDiv` of all private attributes. See below for parameter information. |

‎src/factory.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,22 @@ export default function plotComponentFactory(Plotly) {
103103
UNSAFE_componentWillUpdate(nextProps) {
104104
this.unmounting = false;
105105

106-
if (nextProps.revision !== void 0 && nextProps.revision === this.props.revision) {
107-
// if revision is set and unchanged, do nothing
108-
return;
109-
}
110-
106+
// frames *always* changes identity so fall back to check length only :(
111107
const numPrevFrames =
112108
this.props.frames && this.props.frames.length ? this.props.frames.length : 0;
113109
const numNextFrames =
114110
nextProps.frames && nextProps.frames.length ? nextProps.frames.length : 0;
115-
if (
111+
112+
const figureChanged = !(
116113
nextProps.layout === this.props.layout &&
117114
nextProps.data === this.props.data &&
118115
nextProps.config === this.props.config &&
119116
numNextFrames === numPrevFrames
120-
) {
121-
// prevent infinite loops when component is re-rendered after onUpdate
122-
// frames *always* changes identity so fall back to check length only :(
117+
);
118+
const revisionDefined = nextProps.revision !== void 0;
119+
const revisionChanged = nextProps.revision !== this.props.revision;
120+
121+
if (!figureChanged && (!revisionDefined || (revisionDefined && !revisionChanged))) {
123122
return;
124123
}
125124

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /