Skip to content

Commit 1df0c42

Browse files
committed
centralize inside tick label position test
1 parent b7855ce commit 1df0c42

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/plots/cartesian/axes.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ function formatDate(ax, out, hover, extraPrecision) {
14521452
ax._prevDateHead = headStr;
14531453
dateStr += '<br>' + headStr;
14541454
} else {
1455-
var isInside = (ax.ticklabelposition || '').indexOf('inside') !== -1;
1455+
var isInside = insideTicklabelposition(ax);
14561456
var side = ax._realSide || ax.side; // polar mocks the side of the radial axis
14571457
if(
14581458
(!isInside && side === 'top') ||
@@ -2870,7 +2870,7 @@ axes.drawGrid = function(gd, ax, opts) {
28702870
.style('stroke-width', ax._gw + 'px')
28712871
.style(VISIBLE);
28722872

2873-
if(((ax._anchorAxis || {}).ticklabelposition || '').indexOf('inside') !== -1) {
2873+
if(insideTicklabelposition(ax._anchorAxis || {})) {
28742874
if(ax._hideCounterAxisInsideTickLabels) {
28752875
ax._hideCounterAxisInsideTickLabels();
28762876
}
@@ -3008,7 +3008,7 @@ axes.drawLabels = function(gd, ax, opts) {
30083008
}
30093009

30103010
function positionLabels(s, angle) {
3011-
var isInside = (ax.ticklabelposition || '').indexOf('inside') !== -1;
3011+
var isInside = insideTicklabelposition(ax);
30123012

30133013
s.each(function(d) {
30143014
var thisLabel = d3.select(this);
@@ -3053,7 +3053,7 @@ axes.drawLabels = function(gd, ax, opts) {
30533053
}
30543054

30553055
ax._hideOutOfRangeInsideTickLabels = function() {
3056-
if((ax.ticklabelposition || '').indexOf('inside') !== -1) {
3056+
if(insideTicklabelposition(ax)) {
30573057
var rl = Lib.simpleMap(ax.range, ax.r2l);
30583058

30593059
// hide inside tick labels that go outside axis end points
@@ -3099,7 +3099,7 @@ axes.drawLabels = function(gd, ax, opts) {
30993099
};
31003100

31013101
ax._hideCounterAxisInsideTickLabels = function() {
3102-
if(((ax._anchorAxis || {}).ticklabelposition || '').indexOf('inside') !== -1) {
3102+
if(insideTicklabelposition(ax._anchorAxis || {})) {
31033103
var grid = opts.plotinfo.gridlayer.select('.' + ax._id);
31043104
grid.each(function() {
31053105
d3.select(this).selectAll('path').each(function(d) {
@@ -3240,7 +3240,7 @@ axes.drawLabels = function(gd, ax, opts) {
32403240
var anchorAx = ax._anchorAxis;
32413241
if(
32423242
anchorAx && anchorAx.autorange &&
3243-
(ax.ticklabelposition || '').indexOf('inside') !== -1 &&
3243+
insideTicklabelposition(ax) &&
32443244
!isLinked(fullLayout, ax._id)
32453245
) {
32463246
if(!fullLayout._insideTickLabelsAutorange) {
@@ -3389,7 +3389,7 @@ function drawTitle(gd, ax) {
33893389
if(ax.title.hasOwnProperty('standoff')) {
33903390
titleStandoff = ax._depth + ax.title.standoff + approxTitleDepth(ax);
33913391
} else {
3392-
var isInside = (ax.ticklabelposition || '').indexOf('inside') !== -1;
3392+
var isInside = insideTicklabelposition(ax);
33933393

33943394
if(ax.type === 'multicategory') {
33953395
titleStandoff = ax._depth;
@@ -3747,3 +3747,7 @@ function moveOutsideBreak(v, ax) {
37473747
}
37483748
return v;
37493749
}
3750+
3751+
function insideTicklabelposition(ax) {
3752+
return ((ax.ticklabelposition || '').indexOf('inside') !== -1);
3753+
}

0 commit comments

Comments
 (0)