Skip to content

Commit 6e317d4

Browse files
Improved tickmode schema declaration
1 parent 04cc07e commit 6e317d4

File tree

8 files changed

+30
-89
lines changed

8 files changed

+30
-89
lines changed

src/components/colorbar/attributes.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,7 @@ module.exports = overrideAll({
129129
description: 'Sets the color of padded area.'
130130
},
131131
// tick and title properties named and function exactly as in axes
132-
tickmode: extendFlat({}, axesAttrs.tickmode, {
133-
values: ['auto', 'linear', 'array'],
134-
description: [
135-
'Sets the tick mode for this axis.',
136-
'If *auto*, the number of ticks is set via `nticks`.',
137-
'If *linear*, the placement of the ticks is determined by',
138-
'a starting position `tick0` and a tick step `dtick`',
139-
'(*linear* is the default value if `tick0` and `dtick` are provided).',
140-
'If *array*, the placement of the ticks is set via `tickvals`',
141-
'and the tick text is `ticktext`.',
142-
'(*array* is the default value if `tickvals` is provided).'
143-
].join(' ')
144-
}),
132+
tickmode: axesAttrs.minor.tickmode,
145133
nticks: axesAttrs.nticks,
146134
tick0: axesAttrs.tick0,
147135
dtick: axesAttrs.dtick,

src/plots/cartesian/layout_attributes.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,31 @@ var constants = require('./constants');
1212
var HOUR = constants.HOUR_PATTERN;
1313
var DAY_OF_WEEK = constants.WEEKDAY_PATTERN;
1414

15-
function makeTickmode(minor) {
16-
var values = ['auto', 'linear', 'array', 'sync'];
17-
var description = [
15+
var minorTickmode = {
16+
valType: 'enumerated',
17+
values: ['auto', 'linear', 'array'],
18+
editType: 'ticks',
19+
impliedEdits: {tick0: undefined, dtick: undefined},
20+
description: [
1821
'Sets the tick mode for this axis.',
1922
'If *auto*, the number of ticks is set via `nticks`.',
2023
'If *linear*, the placement of the ticks is determined by',
2124
'a starting position `tick0` and a tick step `dtick`',
2225
'(*linear* is the default value if `tick0` and `dtick` are provided).',
2326
'If *array*, the placement of the ticks is set via `tickvals`',
2427
'and the tick text is `ticktext`.',
25-
'(*array* is the default value if `tickvals` is provided).',
28+
'(*array* is the default value if `tickvals` is provided).'
29+
].join(' ')
30+
};
31+
32+
var tickmode = extendFlat({}, minorTickmode, {
33+
values: minorTickmode.values.slice().concat(['sync']),
34+
description: [
35+
minorTickmode.description,
2636
'If *sync*, the number of ticks will sync with the overlayed axis',
2737
'set by `overlaying` property.'
28-
];
29-
30-
if(minor) {
31-
values = values.slice(0, -1);
32-
description = description.slice(0, -2);
33-
}
34-
35-
return {
36-
valType: 'enumerated',
37-
values: values,
38-
editType: 'ticks',
39-
impliedEdits: {tick0: undefined, dtick: undefined},
40-
description: description.join(' ')
41-
};
42-
}
38+
].join(' ')
39+
});
4340

4441
function makeNticks(minor) {
4542
return {
@@ -516,7 +513,7 @@ module.exports = {
516513
}),
517514

518515
// ticks
519-
tickmode: makeTickmode(),
516+
tickmode: tickmode,
520517
nticks: makeNticks(),
521518
tick0: tick0,
522519
dtick: dtick,
@@ -959,7 +956,7 @@ module.exports = {
959956
},
960957

961958
minor: {
962-
tickmode: makeTickmode('minor'),
959+
tickmode: minorTickmode,
963960
nticks: makeNticks('minor'),
964961
tick0: tick0,
965962
dtick: dtick,

src/plots/cartesian/position_defaults.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer
8383
// which applied in the calculation below:
8484
if(domain[0] > domain[1] - 1 / 4096) containerOut.domain = dfltDomain;
8585
Lib.noneOrAll(containerIn.domain, containerOut.domain, dfltDomain);
86+
87+
// tickmode sync needs an overlaying axis, otherwise
88+
// we should default it to 'auto'
89+
if(containerOut.tickmode === 'sync') {
90+
containerOut.tickmode = 'auto';
91+
}
8692
}
8793

8894
coerce('layer');

src/plots/cartesian/tick_value_defaults.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe
2626
'auto';
2727
var tickmode = coerce(prefix + 'tickmode', tickmodeDefault);
2828

29-
if(tickmode === 'auto') {
29+
if(tickmode === 'auto' || tickmode === 'sync') {
3030
coerce(prefix + 'nticks');
31-
} else if(tickmode === 'sync') {
32-
coerce('overlaying');
3331
} else if(tickmode === 'linear') {
3432
// dtick is usually a positive number, but there are some
3533
// special strings available for log or date axes

src/plots/gl3d/layout/axis_attributes.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,7 @@ module.exports = overrideAll({
7474
anim: false
7575
}),
7676
// ticks
77-
tickmode: extendFlat({}, axesAttrs.tickmode, {
78-
values: ['auto', 'linear', 'array'],
79-
description: [
80-
'Sets the tick mode for this axis.',
81-
'If *auto*, the number of ticks is set via `nticks`.',
82-
'If *linear*, the placement of the ticks is determined by',
83-
'a starting position `tick0` and a tick step `dtick`',
84-
'(*linear* is the default value if `tick0` and `dtick` are provided).',
85-
'If *array*, the placement of the ticks is set via `tickvals`',
86-
'and the tick text is `ticktext`.',
87-
'(*array* is the default value if `tickvals` is provided).'
88-
].join(' ')
89-
}),
77+
tickmode: axesAttrs.minor.tickmode,
9078
nticks: axesAttrs.nticks,
9179
tick0: axesAttrs.tick0,
9280
dtick: axesAttrs.dtick,

src/plots/polar/layout_attributes.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,7 @@ var axisLineGridAttr = overrideAll({
2323
}, 'plot', 'from-root');
2424

2525
var axisTickAttrs = overrideAll({
26-
tickmode: extendFlat({}, axesAttrs.tickmode, {
27-
values: ['auto', 'linear', 'array'],
28-
description: [
29-
'Sets the tick mode for this axis.',
30-
'If *auto*, the number of ticks is set via `nticks`.',
31-
'If *linear*, the placement of the ticks is determined by',
32-
'a starting position `tick0` and a tick step `dtick`',
33-
'(*linear* is the default value if `tick0` and `dtick` are provided).',
34-
'If *array*, the placement of the ticks is set via `tickvals`',
35-
'and the tick text is `ticktext`.',
36-
'(*array* is the default value if `tickvals` is provided).'
37-
].join(' ')
38-
}),
26+
tickmode: axesAttrs.minor.tickmode,
3927
nticks: axesAttrs.nticks,
4028
tick0: axesAttrs.tick0,
4129
dtick: axesAttrs.dtick,

src/plots/ternary/layout_attributes.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,7 @@ var ternaryAxesAttrs = {
1515
},
1616
color: axesAttrs.color,
1717
// ticks
18-
tickmode: extendFlat({}, axesAttrs.tickmode, {
19-
values: ['auto', 'linear', 'array'],
20-
description: [
21-
'Sets the tick mode for this axis.',
22-
'If *auto*, the number of ticks is set via `nticks`.',
23-
'If *linear*, the placement of the ticks is determined by',
24-
'a starting position `tick0` and a tick step `dtick`',
25-
'(*linear* is the default value if `tick0` and `dtick` are provided).',
26-
'If *array*, the placement of the ticks is set via `tickvals`',
27-
'and the tick text is `ticktext`.',
28-
'(*array* is the default value if `tickvals` is provided).'
29-
].join(' ')
30-
}),
18+
tickmode: axesAttrs.minor.tickmode,
3119
nticks: extendFlat({}, axesAttrs.nticks, {dflt: 6, min: 1}),
3220
tick0: axesAttrs.tick0,
3321
dtick: axesAttrs.dtick,

src/traces/indicator/attributes.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -307,19 +307,7 @@ module.exports = {
307307
dflt: true
308308
}),
309309
// tick and title properties named and function exactly as in axes
310-
tickmode: extendFlat({}, axesAttrs.tickmode, {
311-
values: ['auto', 'linear', 'array'],
312-
description: [
313-
'Sets the tick mode for this axis.',
314-
'If *auto*, the number of ticks is set via `nticks`.',
315-
'If *linear*, the placement of the ticks is determined by',
316-
'a starting position `tick0` and a tick step `dtick`',
317-
'(*linear* is the default value if `tick0` and `dtick` are provided).',
318-
'If *array*, the placement of the ticks is set via `tickvals`',
319-
'and the tick text is `ticktext`.',
320-
'(*array* is the default value if `tickvals` is provided).'
321-
].join(' ')
322-
}),
310+
tickmode: axesAttrs.minor.tickmode,
323311
nticks: axesAttrs.nticks,
324312
tick0: axesAttrs.tick0,
325313
dtick: axesAttrs.dtick,

0 commit comments

Comments
 (0)