Skip to content

Commit 2361958

Browse files
committed
revise ticklabelposition supply defaults
1 parent e840f8f commit 2361958

File tree

2 files changed

+23
-34
lines changed

2 files changed

+23
-34
lines changed

src/plots/cartesian/axis_defaults.js

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,33 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
5454
var axTemplate = containerOut._template || {};
5555
var axType = containerOut.type || axTemplate.type || '-';
5656

57+
var ticklabelmode;
5758
if(axType === 'date') {
5859
var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleDefaults');
5960
handleCalendarDefaults(containerIn, containerOut, 'calendar', options.calendar);
6061

6162
if(!options.noTicklabelmode) {
62-
coerce('ticklabelmode');
63+
ticklabelmode = coerce('ticklabelmode');
6364
}
6465
}
6566

6667
if(!options.noTicklabelposition || axType === 'multicategory') {
67-
coerce('ticklabelposition');
68+
Lib.coerce(containerIn, containerOut, {
69+
ticklabelposition: {
70+
valType: 'enumerated',
71+
dflt: 'outside',
72+
values: ticklabelmode === 'period' ? ['outside', 'inside'] :
73+
letter === 'x' ? [
74+
'outside', 'inside',
75+
'outside left', 'inside left',
76+
'outside right', 'inside right'
77+
] : [
78+
'outside', 'inside',
79+
'outside top', 'inside top',
80+
'outside bottom', 'inside bottom'
81+
]
82+
}
83+
}, 'ticklabelposition');
6884
}
6985

7086
setConvert(containerOut, layoutOut);
@@ -122,38 +138,9 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
122138
) {
123139
var ticksonDflt;
124140
if(isMultiCategory) ticksonDflt = 'boundaries';
125-
coerce('tickson', ticksonDflt);
126-
}
127-
128-
// adjust ticklabelposition to in respect to axis orientation & in-between modes
129-
if(containerOut.ticklabelposition) {
130-
if(letter === 'x') {
131-
containerOut.ticklabelposition =
132-
containerOut.ticklabelposition
133-
.replace(' top', '')
134-
.replace(' bottom', '');
135-
} else if(letter === 'y') {
136-
containerOut.ticklabelposition =
137-
containerOut.ticklabelposition
138-
.replace(' left', '')
139-
.replace(' right', '');
140-
}
141-
142-
if(
143-
containerOut.tickson === 'boundaries' ||
144-
containerOut.ticklabelmode === 'period'
145-
) {
146-
if(letter === 'x') {
147-
containerOut.ticklabelposition =
148-
containerOut.ticklabelposition
149-
.replace(' left', '')
150-
.replace(' right', '');
151-
} else if(letter === 'y') {
152-
containerOut.ticklabelposition =
153-
containerOut.ticklabelposition
154-
.replace(' top', '')
155-
.replace(' bottom', '');
156-
}
141+
var tickson = coerce('tickson', ticksonDflt);
142+
if(tickson === 'boundaries') {
143+
delete containerOut.ticklabelposition;
157144
}
158145
}
159146

src/plots/cartesian/layout_attributes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ module.exports = {
505505
'between ticks.'
506506
].join(' ')
507507
},
508+
// ticklabelposition: not used directly, as values depend on direction (similar to side)
509+
// left/right options are for x axes, and top/bottom options are for y axes
508510
ticklabelposition: {
509511
valType: 'enumerated',
510512
values: [

0 commit comments

Comments
 (0)