Skip to content

Commit 898c39d

Browse files
committed
hacky handling for reshaped arrays in Plotly.react
1 parent afc05c9 commit 898c39d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/plot_api/plot_api.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,6 +2490,13 @@ function getDiffFlags(oldContainer, newContainer, outerparts, opts) {
24902490
}
24912491
else if(canBeDataArray) {
24922492
if(wasArray && nowArray) {
2493+
// hack for traces that modify the data in supplyDefaults, like
2494+
// converting 1D to 2D arrays, which will always create new objects
2495+
var inputKey = '_input_' + key;
2496+
var oldValIn = oldContainer[inputKey];
2497+
var newValIn = newContainer[inputKey];
2498+
if(Array.isArray(oldValIn) && oldValIn === newValIn) continue;
2499+
24932500
// don't try to diff two data arrays. If immutable we know the data changed,
24942501
// if not, assume it didn't and let `layout.datarevision` tell us if it did
24952502
if(immutable) {

src/traces/heatmap/convert_column_xyz.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,13 @@ module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name,
7070
}
7171
}
7272

73+
// hack for Plotly.react - save the input arrays for diffing purposes
74+
trace['_input_' + var1Name] = trace[var1Name];
75+
trace['_input_' + var2Name] = trace[var2Name];
7376
trace[var1Name] = col1vals;
7477
trace[var2Name] = col2vals;
7578
for(j = 0; j < arrayVarNames.length; j++) {
79+
trace['_input_' + arrayVarNames[j]] = trace[arrayVarNames[j]];
7680
trace[arrayVarNames[j]] = newArrays[j];
7781
}
7882
if(hasColumnText) trace.text = text;

0 commit comments

Comments
 (0)