-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Transformed array on zoom fix #1717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ var d3 = require('d3'); | |
var isNumeric = require('fast-isnumeric'); | ||
|
||
var Plotly = require('../plotly'); | ||
var PlotSchema = require('../plot_api/plot_schema'); | ||
var Registry = require('../registry'); | ||
var Lib = require('../lib'); | ||
var Color = require('../components/color'); | ||
|
@@ -505,12 +506,38 @@ plots.supplyDefaults = function(gd) { | |
// update object references in calcdata | ||
if((gd.calcdata || []).length === newFullData.length) { | ||
for(i = 0; i < newFullData.length; i++) { | ||
var trace = newFullData[i]; | ||
(gd.calcdata[i][0] || {}).trace = trace; | ||
var newTrace = newFullData[i]; | ||
var cd0 = gd.calcdata[i][0]; | ||
if(cd0 && cd0.trace) { | ||
if(cd0.trace._hasCalcTransform) { | ||
remapTransformedArrays(cd0, newTrace); | ||
} else { | ||
cd0.trace = newTrace; | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
function remapTransformedArrays(cd0, newTrace) { | ||
var oldTrace = cd0.trace; | ||
var arrayAttrs = PlotSchema.findArrayAttributes(oldTrace); | ||
var transformedArrayHash = {}; | ||
var i, ast; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🐄 just so I don't get confused, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh right, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in 0a4ce1f |
||
|
||
for(i = 0; i < arrayAttrs.length; i++) { | ||
ast = arrayAttrs[i]; | ||
transformedArrayHash[ast] = Lib.nestedProperty(oldTrace, ast).get().slice(); | ||
} | ||
|
||
cd0.trace = newTrace; | ||
|
||
for(i = 0; i < arrayAttrs.length; i++) { | ||
ast = arrayAttrs[i]; | ||
Lib.nestedProperty(cd0.trace, ast).set(transformedArrayHash[ast]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we make sure that the array attributes in |
||
} | ||
} | ||
|
||
// Create storage for all of the data related to frames and transitions: | ||
plots.createTransitionData = function(gd) { | ||
// Set up the default keyframe if it doesn't exist: | ||
|
@@ -2022,6 +2049,7 @@ plots.doCalcdata = function(gd, traces) { | |
|
||
_module = transformsRegistry[transform.type]; | ||
if(_module && _module.calcTransform) { | ||
trace._hasCalcTransform = true; | ||
hasCalcTransform = true; | ||
_module.calcTransform(gd, trace, transform); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block updates the
gd.calcdata[i][0].trace
reference so that the plot step can use the correctfullData
attribute values even in cases wherePlots.doCalcdata
isn't called (e.g. on zoom).