Skip to content

Commit 35268c7

Browse files
use flaglist with non-string extra parameters
1 parent 0702b78 commit 35268c7

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

src/lib/coerce.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,14 @@ exports.valObjectMeta = {
215215
requiredOpts: ['flags'],
216216
otherOpts: ['dflt', 'extras', 'arrayOk'],
217217
coerceFunction: function(v, propOut, dflt, opts) {
218-
if(typeof v !== 'string') {
219-
propOut.set(dflt);
220-
return;
221-
}
222218
if((opts.extras || []).indexOf(v) !== -1) {
223219
propOut.set(v);
224220
return;
225221
}
222+
if(typeof v !== 'string') {
223+
propOut.set(dflt);
224+
return;
225+
}
226226
var vParts = v.split('+');
227227
var i = 0;
228228
while(i < vParts.length) {

src/plots/cartesian/layout_attributes.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -625,14 +625,9 @@ module.exports = {
625625
description: 'Determines whether or not the tick labels are drawn.'
626626
},
627627
automargin: {
628-
valType: 'enumerated',
629-
values: [
630-
true, false, 'height', 'width',
631-
'top', 'bottom', 'left', 'right',
632-
'top left', 'top width', 'top right',
633-
'left height', 'right height',
634-
'bottom left', 'bottom width', 'bottom right',
635-
],
628+
valType: 'flaglist',
629+
flags: ['height', 'width', 'left', 'right', 'top', 'bottom'],
630+
extras: [true, false],
636631
dflt: false,
637632
editType: 'ticks',
638633
description: [

test/jasmine/tests/axes_test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -4284,15 +4284,15 @@ describe('Test axes', function() {
42844284
t: 'grew', l: 'grew',
42854285
b: '=', r: '='
42864286
}))
4287-
.then(check('automargin not left', {'yaxis.automargin': 'right height'}, {
4287+
.then(check('automargin not left', {'yaxis.automargin': 'right+height'}, {
42884288
t: 'grew', l: '=',
42894289
b: '=', r: '='
42904290
}))
4291-
.then(check('automargin keep left height', {'yaxis.automargin': 'left height'}, {
4291+
.then(check('automargin keep left height', {'yaxis.automargin': 'left+height'}, {
42924292
t: 'grew', l: 'grew',
42934293
b: '=', r: '='
42944294
}))
4295-
.then(check('automargin keep bottom right', {'yaxis.automargin': 'bottom right'}, {
4295+
.then(check('automargin keep bottom right', {'yaxis.automargin': 'bottom+right'}, {
42964296
t: '=', l: '=',
42974297
b: '=', r: '='
42984298
}))
@@ -4304,7 +4304,7 @@ describe('Test axes', function() {
43044304
t: 'grew', l: '=',
43054305
b: '=', r: '='
43064306
}))
4307-
.then(check('automargin not top', {'yaxis.automargin': 'bottom width'}, {
4307+
.then(check('automargin not top', {'yaxis.automargin': 'bottom+width'}, {
43084308
t: '=', l: 'grew',
43094309
b: '=', r: '='
43104310
}))
@@ -4320,7 +4320,7 @@ describe('Test axes', function() {
43204320
t: '=', l: '=',
43214321
b: 'grew', r: 'grew'
43224322
}))
4323-
.then(check('automargin not bottom', {'xaxis.automargin': 'top width'}, {
4323+
.then(check('automargin not bottom', {'xaxis.automargin': 'top+width'}, {
43244324
t: '=', l: '=',
43254325
b: '=', r: 'grew'
43264326
}))
@@ -4332,15 +4332,15 @@ describe('Test axes', function() {
43324332
t: '=', l: '=',
43334333
b: 'grew', r: '='
43344334
}))
4335-
.then(check('automargin keep top right', {'xaxis.automargin': 'top right'}, {
4335+
.then(check('automargin keep top right', {'xaxis.automargin': 'top+right'}, {
43364336
t: '=', l: '=',
43374337
b: '=', r: 'grew'
43384338
}))
4339-
.then(check('automargin keep top left', {'xaxis.automargin': 'top left'}, {
4339+
.then(check('automargin keep top left', {'xaxis.automargin': 'top+left'}, {
43404340
t: '=', l: '=',
43414341
b: '=', r: '='
43424342
}))
4343-
.then(check('automargin keep bottom left', {'xaxis.automargin': 'bottom left'}, {
4343+
.then(check('automargin keep bottom left', {'xaxis.automargin': 'bottom+left'}, {
43444344
t: '=', l: '=',
43454345
b: 'grew', r: '='
43464346
}))

0 commit comments

Comments
 (0)