Skip to content

Commit 837761c

Browse files
committed
maintain detecting dates using strict mode
1 parent f1c0e31 commit 837761c

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/plots/cartesian/axis_autotype.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = function autoType(array, calendar, opts) {
1818
var convertNumeric = opts.autotypenumbers !== 'strict'; // compare against strict, just in case autotypenumbers was not provided in opts
1919

2020
if(!opts.noMultiCategory && multiCategory(array)) return 'multicategory';
21-
if(convertNumeric && moreDates(array, calendar)) return 'date';
21+
if(moreDates(array, calendar)) return 'date';
2222
if(category(array)) return 'category';
2323
if(linearOK(array)) return 'linear';
2424
else return convertNumeric ? '-' : 'category';

test/jasmine/tests/axes_test.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,47 @@ describe('Test axes', function() {
378378
expect(layoutOut.xaxis.type).toBe('linear');
379379
expect(layoutOut.yaxis.type).toBe('category');
380380
});
381+
382+
it('should autotype date having more dates with & without strict autotypenumbers', function() {
383+
layoutIn = {
384+
xaxis: {},
385+
yaxis: { autotypenumbers: 'strict' }
386+
};
387+
388+
var dates = [
389+
0,
390+
'0',
391+
'00',
392+
'0000',
393+
'1970',
394+
'2000',
395+
'2001-01',
396+
'2001-02',
397+
'2001-03',
398+
'2001-04',
399+
'2001-05',
400+
'2001-06',
401+
'2001-07',
402+
'2001-08',
403+
'2001-09',
404+
'2001-10',
405+
'2001-11',
406+
'2001-12'
407+
];
408+
409+
supplyLayoutDefaults(layoutIn, layoutOut, [{
410+
type: 'scatter',
411+
xaxis: 'x',
412+
yaxis: 'y',
413+
x: dates,
414+
y: dates
415+
}]);
416+
417+
expect(layoutOut.xaxis.autotypenumbers).toBe('convert types');
418+
expect(layoutOut.yaxis.autotypenumbers).toBe('strict');
419+
expect(layoutOut.xaxis.type).toBe('date');
420+
expect(layoutOut.yaxis.type).toBe('date');
421+
});
381422
});
382423

383424
it('should set undefined linewidth/linecolor if linewidth, linecolor or showline is not supplied', function() {

0 commit comments

Comments
 (0)