Skip to content

Commit f9db523

Browse files
committed
cast bad size values to zero instead of NaN - fixup scattergeo jasmine test
1 parent 39b9840 commit f9db523

File tree

5 files changed

+18
-32
lines changed

5 files changed

+18
-32
lines changed

src/lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ lib.mergeArray = function(traceAttr, cd, cdAttr, fn) {
474474
lib.mergeArrayCastPositive = function(traceAttr, cd, cdAttr) {
475475
return lib.mergeArray(traceAttr, cd, cdAttr, function(v) {
476476
var w = +v;
477-
return isNaN(w) ? NaN : w > 0 ? w : 0;
477+
return !isFinite(w) ? 0 : w > 0 ? w : 0;
478478
});
479479
};
480480

test/jasmine/tests/bar_test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -412,14 +412,14 @@ describe('Bar.calc', function() {
412412
var gd = mockBarPlot([{
413413
marker: {
414414
line: {
415-
width: [2, 1, 0, -1, false, true, null, [], -Infinity, Infinity, NaN, {}]
415+
width: [2, 1, 0, -1, false, true, null, [], -Infinity, Infinity, NaN, {}, '12+1', '1e1']
416416
}
417417
},
418-
y: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
418+
y: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
419419
}], {});
420420

421421
var cd = gd.calcdata;
422-
assertPointField(cd, 'mlw', [[2, 1, 0, 0, 0, 1, 0, 0, 0, Infinity, NaN, NaN]]);
422+
assertPointField(cd, 'mlw', [[2, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 10]]);
423423
});
424424
});
425425

test/jasmine/tests/funnel_test.js

+3-17
Original file line numberDiff line numberDiff line change
@@ -356,28 +356,14 @@ describe('Funnel.calc', function() {
356356
var gd = mockFunnelPlot([{
357357
marker: {
358358
line: {
359-
width: [2, 1, 0, -1, false, true, null, [], -Infinity, Infinity, NaN, {}]
359+
width: [2, 1, 0, -1, false, true, null, [], -Infinity, Infinity, NaN, {}, '12+1', '1e1']
360360
}
361361
},
362-
y: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
362+
y: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
363363
}], {});
364364

365365
var cd = gd.calcdata;
366-
assertPointField(cd, 'mlw', [[2, 1, 0, 0, 0, 1, 0, 0, 0, Infinity, NaN, NaN]]);
367-
});
368-
369-
it('should guard against negative marker.line.width values', function() {
370-
var gd = mockFunnelPlot([{
371-
marker: {
372-
line: {
373-
width: [2, 1, 0, -1, false, true, null, [], -Infinity, Infinity, NaN, {}]
374-
}
375-
},
376-
y: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
377-
}], {});
378-
379-
var cd = gd.calcdata;
380-
assertPointField(cd, 'mlw', [[2, 1, 0, 0, 0, 1, 0, 0, 0, Infinity, NaN, NaN]]);
366+
assertPointField(cd, 'mlw', [[2, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 10]]);
381367
});
382368
});
383369

test/jasmine/tests/scatter_test.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,16 @@ describe('Test scatter', function() {
298298
mode: 'markers+text',
299299
marker: {
300300
line: {
301-
width: [2, 1, 0, -1, false, true, null, [], -Infinity, Infinity, NaN, {}]
301+
width: [2, 1, 0, -1, false, true, null, [], -Infinity, Infinity, NaN, {}, '12+1', '1e1']
302302
},
303-
opacity: [2, 1, 0, -1, false, true, null, [], -Infinity, Infinity, NaN, {}],
304-
size: [2, 1, 0, -1, false, true, null, [], -Infinity, Infinity, NaN, {}]
303+
opacity: [2, 1, 0, -1, false, true, null, [], -Infinity, Infinity, NaN, {}, '12+1', '1e1'],
304+
size: [2, 1, 0, -1, false, true, null, [], -Infinity, Infinity, NaN, {}, '12+1', '1e1']
305305
},
306306
textfont: {
307-
size: [2, 1, 0, -1, false, true, null, [], -Infinity, Infinity, NaN, {}]
307+
size: [2, 1, 0, -1, false, true, null, [], -Infinity, Infinity, NaN, {}, '12+1', '1e1']
308308
},
309-
text: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
310-
y: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
309+
text: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14'],
310+
y: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
311311
}],
312312
layout: {},
313313
calcdata: [],
@@ -318,10 +318,10 @@ describe('Test scatter', function() {
318318
Plots.doCalcdata(gd);
319319

320320
var cd = gd.calcdata;
321-
assertPointField(cd, 'mlw', [[2, 1, 0, 0, 0, 1, 0, 0, 0, Infinity, NaN, NaN]]);
322-
assertPointField(cd, 'mo', [[2, 1, 0, 0, 0, 1, 0, 0, 0, Infinity, NaN, NaN]]);
323-
assertPointField(cd, 'ms', [[2, 1, 0, 0, 0, 1, 0, 0, 0, Infinity, NaN, NaN]]);
324-
assertPointField(cd, 'ts', [[2, 1, 0, 0, 0, 1, 0, 0, 0, Infinity, NaN, NaN]]);
321+
assertPointField(cd, 'mlw', [[2, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 10]]);
322+
assertPointField(cd, 'mo', [[2, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 10]]);
323+
assertPointField(cd, 'ms', [[2, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 10]]);
324+
assertPointField(cd, 'ts', [[2, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 10]]);
325325
});
326326
});
327327

test/jasmine/tests/scattergeo_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ describe('Test scattergeo calc', function() {
215215

216216
expect(calcTrace).toEqual([
217217
{ lonlat: [10, 20], mc: 0, ms: 10 },
218-
{ lonlat: [20, 30], mc: null, ms: NaN },
218+
{ lonlat: [20, 30], mc: null, ms: 0 },
219219
{ lonlat: [BADNUM, BADNUM], mc: 5, ms: 8 },
220220
{ lonlat: [30, 10], mc: 10, ms: 10 }
221221
]);

0 commit comments

Comments
 (0)