-
-
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
Typed arrays support #2388
Typed arrays support #2388
Changes from 9 commits
91b03ff
a25ff13
45c2f35
2d81bdc
bcf59d7
bc32981
2372629
909120e
5316c47
0aa0f5e
39ef5a9
36b4e25
40f93f7
d98dcc0
c0e2f73
09d37b6
a7ed2c2
b95e462
53ea0ec
98d2407
01a8443
c15722f
a2fb88b
f0395b5
9b83826
6dd2f69
306986d
d4cb0c4
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 |
---|---|---|
|
@@ -8,15 +8,13 @@ | |
|
||
'use strict'; | ||
|
||
/** | ||
* Return true for arrays, whether they're untyped or not. | ||
*/ | ||
|
||
// IE9 fallback | ||
var ab = (typeof ArrayBuffer === 'undefined' || !ArrayBuffer.isView) ? | ||
{isView: function() { return false; }} : | ||
ArrayBuffer; | ||
|
||
module.exports = function isArray(a) { | ||
exports.isTypedArray = ab.isView; | ||
|
||
exports.isArrayOrTypedArray = function(a) { | ||
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. perusing https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView - there's also 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. improved in f0395b5 |
||
return Array.isArray(a) || ab.isView(a); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,25 +405,34 @@ module.exports = function setConvert(ax, fullLayout) { | |
if(axLetter in trace) { | ||
arrayIn = trace[axLetter]; | ||
len = trace._length || arrayIn.length; | ||
arrayOut = new Array(len); | ||
|
||
if(Lib.isTypedArray(arrayIn)) { | ||
if(len === arrayIn.length) { | ||
return arrayIn; | ||
} else if(arrayIn.subarray) { | ||
return arrayIn.subarray(0, len); | ||
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. This should work for linear and log axes, but what happens if you feed numeric data to a non-numeric (date or category) axis? Both of those could be real use cases, but both also alter the input numbers, so I think they need to bail out to the 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 and 🔒 in 6dd2f69 |
||
} | ||
} | ||
|
||
arrayOut = new Array(len); | ||
for(i = 0; i < len; i++) { | ||
arrayOut[i] = ax.d2c(arrayIn[i], 0, cal); | ||
} | ||
} | ||
else { | ||
var v0 = ((axLetter + '0') in trace) ? | ||
ax.d2c(trace[axLetter + '0'], 0, cal) : 0, | ||
dv = (trace['d' + axLetter]) ? | ||
Number(trace['d' + axLetter]) : 1; | ||
var v0 = ((axLetter + '0') in trace) ? ax.d2c(trace[axLetter + '0'], 0, cal) : 0; | ||
var dv = (trace['d' + axLetter]) ? Number(trace['d' + axLetter]) : 1; | ||
|
||
// the opposing data, for size if we have x and dx etc | ||
arrayIn = trace[{x: 'y', y: 'x'}[axLetter]]; | ||
len = trace._length || arrayIn.length; | ||
arrayOut = new Array(len); | ||
|
||
for(i = 0; i < len; i++) arrayOut[i] = v0 + i * dv; | ||
for(i = 0; i < len; i++) { | ||
arrayOut[i] = v0 + i * dv; | ||
} | ||
} | ||
|
||
return arrayOut; | ||
}; | ||
|
||
|
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.
again to my question about missing data in typed arrays... here can't we just let these typed arrays drop into the for loop as well?
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.
done and 🔒 in 306986d