Skip to content

Commit fb67c82

Browse files
committed
revise new attribute names and val types
1 parent 01115cd commit fb67c82

21 files changed

+118
-91
lines changed

src/plots/cartesian/axes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ var getDataConversions = axes.getDataConversions = function(gd, trace, target, t
217217
if(Array.isArray(d2cTarget)) {
218218
ax = {
219219
type: autoType(targetArray, undefined, {
220-
convertNumeric: gd._fullLayout.axesconvertnumeric
220+
autotypenumbers: gd._fullLayout.autotypenumbers
221221
}),
222222
_categories: []
223223
};

src/plots/cartesian/axis_autotype.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ var Lib = require('../../lib');
1515
var BADNUM = require('../../constants/numerical').BADNUM;
1616

1717
module.exports = function autoType(array, calendar, opts) {
18-
var convertNumeric = opts.convertNumeric;
18+
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';
2121
if(convertNumeric && moreDates(array, calendar)) return 'date';
2222
if(category(array)) return 'category';
23-
if(linearOK(array, convertNumeric)) return 'linear';
23+
if(linearOK(array)) return 'linear';
2424
else return convertNumeric ? '-' : 'category';
2525
};
2626

src/plots/cartesian/layout_attributes.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,17 @@ module.exports = {
102102
'the axis in question.'
103103
].join(' ')
104104
},
105-
convertnumeric: {
106-
valType: 'boolean',
105+
autotypenumbers: {
106+
valType: 'enumerated',
107+
values: ['convert types', 'strict'],
108+
dflt: 'convert types',
107109
role: 'info',
108110
editType: 'calc',
109111
description: [
110-
'Determines whether or not a numeric string in data for this axis may be',
112+
'Using *strict* a numeric string in trace data is not converted to a number.',
113+
'Using *accept strings* a numeric string in trace data may be',
111114
'treated as a number during automatic axis `type` detection.',
112-
'Defaults to layout.axesconvertnumeric.'
115+
'Defaults to layout.autotypenumbers.'
113116
].join(' ')
114117
},
115118
autorange: {

src/plots/cartesian/layout_defaults.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function appendList(cont, k, item) {
3838
}
3939

4040
module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
41-
var convertnumericDflt = layoutOut.axesconvertnumeric;
41+
var autotypenumbersDflt = layoutOut.autotypenumbers;
4242

4343
var ax2traces = {};
4444
var xaMayHide = {};
@@ -248,7 +248,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
248248
automargin: true,
249249
visibleDflt: visibleDflt,
250250
reverseDflt: reverseDflt,
251-
convertnumericDflt: convertnumericDflt,
251+
autotypenumbersDflt: autotypenumbersDflt,
252252
splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[axId]
253253
};
254254

@@ -313,7 +313,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
313313
automargin: true,
314314
visibleDflt: false,
315315
reverseDflt: false,
316-
convertnumericDflt: convertnumericDflt,
316+
autotypenumbersDflt: autotypenumbersDflt,
317317
splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[axId]
318318
};
319319

src/plots/cartesian/type_defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var autoType = require('./axis_autotype');
1616
* name: axis object name (ie 'xaxis') if one should be stored
1717
*/
1818
module.exports = function handleTypeDefaults(containerIn, containerOut, coerce, options) {
19-
coerce('convertnumeric', options.convertnumericDflt);
19+
coerce('autotypenumbers', options.autotypenumbersDflt);
2020
var axType = coerce('type', (options.splomStash || {}).type);
2121

2222
if(axType === '-') {
@@ -69,7 +69,7 @@ function setAutoType(ax, data) {
6969
opts.noMultiCategory = true;
7070
}
7171

72-
opts.convertNumeric = ax.convertnumeric;
72+
opts.autotypenumbers = ax.autotypenumbers;
7373

7474
// check all boxes on this x axis to see
7575
// if they're dates, numbers, or categories

src/plots/gl3d/layout/axis_attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module.exports = overrideAll({
7878
type: extendFlat({}, axesAttrs.type, {
7979
values: ['-', 'linear', 'log', 'date', 'category']
8080
}),
81-
convertnumeric: axesAttrs.convertnumeric,
81+
autotypenumbers: axesAttrs.autotypenumbers,
8282
autorange: axesAttrs.autorange,
8383
rangemode: axesAttrs.rangemode,
8484
range: extendFlat({}, axesAttrs.range, {

src/plots/gl3d/layout/defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
4040
font: layoutOut.font,
4141
fullData: fullData,
4242
getDfltFromLayout: getDfltFromLayout,
43-
convertnumericDflt: layoutOut.axesconvertnumeric,
43+
autotypenumbersDflt: layoutOut.autotypenumbers,
4444
paper_bgcolor: layoutOut.paper_bgcolor,
4545
calendar: layoutOut.calendar
4646
});
@@ -110,7 +110,7 @@ function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) {
110110
data: fullGl3dData,
111111
bgColor: bgColorCombined,
112112
calendar: opts.calendar,
113-
convertnumericDflt: opts.convertnumericDflt,
113+
autotypenumbersDflt: opts.autotypenumbersDflt,
114114
fullLayout: opts.fullLayout
115115
});
116116

src/plots/layout_attributes.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,17 @@ module.exports = {
292292
'Sets the background color of the plotting area in-between x and y axes.'
293293
].join(' ')
294294
},
295-
axesconvertnumeric: {
296-
valType: 'boolean',
297-
dflt: true,
295+
autotypenumbers: {
296+
valType: 'enumerated',
297+
values: ['convert types', 'strict'],
298+
dflt: 'convert types',
298299
role: 'info',
299300
editType: 'calc',
300301
description: [
301-
'Determines whether or not a numeric string in trace data may be',
302-
'treated as a number during automatic axis `type` detection.'
302+
'Using *strict* a numeric string in trace data is not converted to a number.',
303+
'Using *accept strings* a numeric string in trace data may be',
304+
'treated as a number during automatic axis `type` detection.',
305+
'This is the default value; however it could be overridden for individual axes.'
303306
].join(' ')
304307
},
305308
separators: {

src/plots/plots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
14761476
layoutOut._dataTemplate = template.data;
14771477
}
14781478

1479-
coerce('axesconvertnumeric');
1479+
coerce('autotypenumbers');
14801480

14811481
var globalFont = Lib.coerceFont(coerce, 'font');
14821482

src/plots/polar/layout_attributes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var radialAxisAttrs = {
6161
type: extendFlat({}, axesAttrs.type, {
6262
values: ['-', 'linear', 'log', 'date', 'category']
6363
}),
64-
convertnumeric: axesAttrs.convertnumeric,
64+
autotypenumbers: axesAttrs.autotypenumbers,
6565

6666
autorange: extendFlat({}, axesAttrs.autorange, {editType: 'plot'}),
6767
rangemode: {
@@ -180,7 +180,7 @@ var angularAxisAttrs = {
180180
'If *category, use `period` to set the number of integer coordinates around polar axis.'
181181
].join(' ')
182182
},
183-
convertnumeric: axesAttrs.convertnumeric,
183+
autotypenumbers: axesAttrs.autotypenumbers,
184184

185185
categoryorder: axesAttrs.categoryorder,
186186
categoryarray: axesAttrs.categoryarray,

src/plots/polar/layout_defaults.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function handleDefaults(contIn, contOut, coerce, opts) {
188188
}
189189

190190
function handleAxisTypeDefaults(axIn, axOut, coerce, subplotData, dataAttr, options) {
191-
var convertnumeric = coerce('convertnumeric', options.convertnumericDflt);
191+
var autotypenumbers = coerce('autotypenumbers', options.autotypenumbersDflt);
192192
var axType = coerce('type');
193193

194194
if(axType === '-') {
@@ -203,7 +203,7 @@ function handleAxisTypeDefaults(axIn, axOut, coerce, subplotData, dataAttr, opti
203203

204204
if(trace && trace[dataAttr]) {
205205
axOut.type = autoType(trace[dataAttr], 'gregorian', {
206-
convertNumeric: convertnumeric
206+
autotypenumbers: autotypenumbers
207207
});
208208
}
209209

@@ -227,7 +227,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
227227
attributes: layoutAttributes,
228228
handleDefaults: handleDefaults,
229229
font: layoutOut.font,
230-
convertnumericDflt: layoutOut.axesconvertnumeric,
230+
autotypenumbersDflt: layoutOut.autotypenumbers,
231231
paper_bgcolor: layoutOut.paper_bgcolor,
232232
fullData: fullData,
233233
layoutOut: layoutOut

src/plots/ternary/layout_defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
2727
attributes: layoutAttributes,
2828
handleDefaults: handleTernaryDefaults,
2929
font: layoutOut.font,
30-
convertnumericDflt: layoutOut.axesconvertnumeric,
30+
autotypenumbersDflt: layoutOut.autotypenumbers,
3131
paper_bgcolor: layoutOut.paper_bgcolor
3232
});
3333
};

src/traces/box/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function handleSampleDefaults(traceIn, traceOut, coerce, layout) {
111111

112112
var calendar = 'gregorian'; // TODO: should we use ax.calendar here?
113113
var opts = {
114-
convertNumeric: true // TODO: should we use ax.convertnumeric here?
114+
autotypenumbers: 'convert types' // TODO: should we use ax.autotypenumbers here?
115115
};
116116

117117
var defaultOrientation, len;

src/traces/carpet/ab_defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function mimickAxisDefaults(traceIn, traceOut, fullLayout, dfltColor) {
4747
calendar: traceOut.calendar,
4848
dfltColor: dfltColor,
4949
bgColor: fullLayout.paper_bgcolor,
50+
autotypenumbersDflt: fullLayout.autotypenumbers,
5051
fullLayout: fullLayout
5152
};
5253

src/traces/carpet/axis_attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports = {
8888
'the axis in question.'
8989
].join(' ')
9090
},
91-
convertnumeric: axesAttrs.convertnumeric,
91+
autotypenumbers: axesAttrs.autotypenumbers,
9292
autorange: {
9393
valType: 'enumerated',
9494
values: [true, false, 'reversed'],

src/traces/carpet/axis_defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options)
5151
}
5252

5353
// now figure out type and do some more initialization
54-
coerce('convertnumeric', options.convertnumericDflt);
54+
coerce('autotypenumbers', options.autotypenumbersDflt);
5555
var axType = coerce('type');
5656
if(axType === '-') {
5757
if(options.data) setAutoType(containerOut, options.data);
@@ -221,6 +221,6 @@ function setAutoType(ax, data) {
221221
var calendar = ax[calAttr];
222222

223223
ax.type = autoType(data, calendar, {
224-
convertNumeric: ax.convertnumeric
224+
autotypenumbers: ax.autotypenumbers
225225
});
226226
}

test/jasmine/tests/axes_test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ describe('Test axes', function() {
190190

191191
beforeEach(function() {
192192
layoutOut = {
193-
axesconvertnumeric: true,
193+
autotypenumbers: 'convert types',
194194
_has: Plots._hasPlotType,
195195
_basePlotModules: [],
196196
_dfltTitle: {x: 'x', y: 'y'},
@@ -337,10 +337,10 @@ describe('Test axes', function() {
337337
});
338338

339339
describe('autotype disable/enable converting numeric strings', function() {
340-
it('should disable converting numeric strings using axis.convertnumeric', function() {
340+
it('should disable converting numeric strings using axis.autotypenumbers', function() {
341341
layoutIn = {
342342
xaxis: {},
343-
yaxis: { convertnumeric: false }
343+
yaxis: { autotypenumbers: 'strict' }
344344
};
345345

346346
supplyLayoutDefaults(layoutIn, layoutOut, [{
@@ -351,17 +351,17 @@ describe('Test axes', function() {
351351
y: ['0', '1', '1970', '2000']
352352
}]);
353353

354-
expect(layoutOut.xaxis.convertnumeric).toBe(true);
355-
expect(layoutOut.yaxis.convertnumeric).toBe(false);
354+
expect(layoutOut.xaxis.autotypenumbers).toBe('convert types');
355+
expect(layoutOut.yaxis.autotypenumbers).toBe('strict');
356356
expect(layoutOut.xaxis.type).toBe('linear');
357357
expect(layoutOut.yaxis.type).toBe('category');
358358
});
359359

360-
it('should enable converting numeric strings using axis.convertnumeric and inherit defaults from layout.axesconvertnumeric', function() {
361-
layoutOut.axesconvertnumeric = false;
360+
it('should enable converting numeric strings using axis.autotypenumbers and inherit defaults from layout.autotypenumbers', function() {
361+
layoutOut.autotypenumbers = 'strict';
362362

363363
layoutIn = {
364-
xaxis: { convertnumeric: true },
364+
xaxis: { autotypenumbers: 'convert types' },
365365
yaxis: {}
366366
};
367367

@@ -373,8 +373,8 @@ describe('Test axes', function() {
373373
y: ['0', '1', '1970', '2000']
374374
}]);
375375

376-
expect(layoutOut.xaxis.convertnumeric).toBe(true);
377-
expect(layoutOut.yaxis.convertnumeric).toBe(false);
376+
expect(layoutOut.xaxis.autotypenumbers).toBe('convert types');
377+
expect(layoutOut.yaxis.autotypenumbers).toBe('strict');
378378
expect(layoutOut.xaxis.type).toBe('linear');
379379
expect(layoutOut.yaxis.type).toBe('category');
380380
});

test/jasmine/tests/box_test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,10 @@ describe('Test boxes supplyDefaults', function() {
637637
});
638638

639639
describe('Test box autoType', function() {
640-
it('should disable converting numeric strings using axis.convertnumeric', function() {
640+
it('should disable converting numeric strings using axis.autotypenumbers', function() {
641641
var gd = {
642642
layout: {
643-
xaxis: { convertnumeric: false }
643+
xaxis: { autotypenumbers: 'strict' }
644644
},
645645
data: [{
646646
type: 'box',
@@ -657,15 +657,15 @@ describe('Test box autoType', function() {
657657

658658
supplyAllDefaults(gd);
659659

660-
expect(gd._fullLayout.xaxis.convertnumeric).toBe(false);
660+
expect(gd._fullLayout.xaxis.autotypenumbers).toBe('strict');
661661
expect(gd._fullLayout.xaxis.type).toBe('category');
662662
});
663663

664-
it('should enable converting numeric strings using axis.convertnumeric', function() {
664+
it('should enable converting numeric strings using axis.autotypenumbers', function() {
665665
var gd = {
666666
layout: {
667-
axesconvertnumeric: false,
668-
xaxis: { convertnumeric: true }
667+
autotypenumbers: 'strict',
668+
xaxis: { autotypenumbers: 'convert types' }
669669
},
670670
data: [{
671671
type: 'box',
@@ -682,14 +682,14 @@ describe('Test box autoType', function() {
682682

683683
supplyAllDefaults(gd);
684684

685-
expect(gd._fullLayout.xaxis.convertnumeric).toBe(true);
685+
expect(gd._fullLayout.xaxis.autotypenumbers).toBe('convert types');
686686
expect(gd._fullLayout.xaxis.type).toBe('linear');
687687
});
688688

689-
it('should enable converting numeric inherit defaults from layout.axesconvertnumeric', function() {
689+
it('should enable converting numeric inherit defaults from layout.autotypenumbers', function() {
690690
var gd = {
691691
layout: {
692-
axesconvertnumeric: false,
692+
autotypenumbers: 'strict',
693693
xaxis: {}
694694
},
695695
data: [{
@@ -707,7 +707,7 @@ describe('Test box autoType', function() {
707707

708708
supplyAllDefaults(gd);
709709

710-
expect(gd._fullLayout.xaxis.convertnumeric).toBe(false);
710+
expect(gd._fullLayout.xaxis.autotypenumbers).toBe('strict');
711711
expect(gd._fullLayout.xaxis.type).toBe('category');
712712
});
713713
});

0 commit comments

Comments
 (0)