Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 69ccfd3

Browse files
committed
fix typed array support on axes with set type:multicategory
1 parent e0111d4 commit 69ccfd3

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/lib/array.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ exports.minRowLength = function(z) {
143143

144144
function _rowLength(z, fn, len0) {
145145
if(isArrayOrTypedArray(z)) {
146-
if(Array.isArray(z[0])) {
146+
if(isArrayOrTypedArray(z[0])) {
147147
var len = len0;
148148
for(var i = 0; i < z.length; i++) {
149149
len = fn(len, z[i].length);

src/plots/cartesian/set_convert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ module.exports = function setConvert(ax, fullLayout) {
155155
// [ [cnt, {$cat: index}], for j .. arrayIn.length ]
156156
var seen = [[0, {}], [0, {}]];
157157

158-
if(Array.isArray(arrayIn[0]) && Array.isArray(arrayIn[1])) {
158+
if(Lib.isArrayOrTypedArray(arrayIn[0]) && Lib.isArrayOrTypedArray(arrayIn[1])) {
159159
for(i = 0; i < len; i++) {
160160
var v0 = arrayIn[0][i];
161161
var v1 = arrayIn[1][i];

test/jasmine/tests/axes_test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,6 +2862,19 @@ describe('Test axes', function() {
28622862
expect(ax._categories).toEqual([]);
28632863
expect(ax._categoriesMap).toEqual(undefined);
28642864
});
2865+
2866+
it('case with inner typed arrays and set type:multicategory', function() {
2867+
var out = _makeCalcdata({
2868+
x: [
2869+
new Float32Array([1, 2, 1, 2]),
2870+
new Float32Array([10, 10, 20, 20])
2871+
]
2872+
}, 'x', 'multicategory');
2873+
2874+
expect(out).toEqual([0, 1, 2, 3]);
2875+
expect(ax._categories).toEqual([[1, 10], [1, 20], [2, 10], [2, 20]]);
2876+
expect(ax._categoriesMap).toEqual({'1,10': 0, '1,20': 1, '2,10': 2, '2,20': 3});
2877+
});
28652878
});
28662879

28672880
describe('2d coordinate array on non-multicategory axes should return BADNUMs', function() {

0 commit comments

Comments
 (0)