-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fix parcoords dimensions values & line coloring error with integer TypedArray #3598
Conversation
Thanks for the fix @archmoj! It looks good to me 👍 I am wondering if we should add a parcoords mock with |
@antoinerg thanks for the review & comment. I am not sure if we could make a JSON mock with typed arrays. So I may add a jasmine test. |
@antoinerg Please note that e8cc760 is also added concerning my comment here. |
You're probably right 😄 Thanks for the jasmine tests! I confirm this PR fix both issues in #3595 but I wonder why Nice work @archmoj |
src/traces/parcoords/defaults.js
Outdated
@@ -49,6 +49,11 @@ function dimensionDefaults(dimensionIn, dimensionOut) { | |||
} | |||
|
|||
var values = coerce('values'); | |||
if(!Array.isArray(values) && Lib.isArrayOrTypedArray(values)) { | |||
// should convert typed arrays e.g. integers to real numbers | |||
values = dimensionOut.values = Array.prototype.slice.call(values); |
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.
Nop. Let's not do this during defaults to remain consistent with other typed-array-to-array blocks.
Move this to parcoords/calc.js
.
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.
If we can keep typed arrays as typed array and handle them correct downstream, then we shouldn't convert them.
That makes perfect sense!
src/traces/parcoords/defaults.js
Outdated
var lineColor = coerce('line.color', defaultColor); | ||
if(!Array.isArray(lineColor) && Lib.isArrayOrTypedArray(lineColor)) { | ||
// should convert typed arrays e.g. integers to real numbers | ||
lineColor = traceOut.line.color = Array.prototype.slice.call(lineColor); |
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.
same here.
because we don't want to do that in general. If we can keep typed arrays as typed array and handle them correctly downstream, then we shouldn't convert them. See for example plotly.js/src/plots/cartesian/set_convert.js Lines 516 to 537 in ecfa45a
|
See #913 |
src/traces/parcoords/calc.js
Outdated
@@ -39,3 +45,11 @@ function constHalf(len) { | |||
} | |||
return out; | |||
} | |||
|
|||
function isTypedArray(a) { |
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.
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.
Nicely done 💃 |
Fixes two issues reported & discovered in #3595 resulted from
integer
rounding errors.color.line
typed arrays e.g. int32dimensions.values
typed arrays e.g. int32@plotly_js
Codepen Before.
Codepen After.