Skip to content

Commit 6420044

Browse files
committed
take the first matching tickformatstop
1 parent 0b48a33 commit 6420044

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

src/plots/cartesian/axes.js

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,40 +1539,26 @@ axes.getTickFormat = function(ax) {
15391539
if(ax.tickformatstops && ax.tickformatstops.length > 0) {
15401540
switch(ax.type) {
15411541
case 'date': {
1542-
tickstop = ax.tickformatstops.reduce(function(acc, stop) {
1543-
if(!isProperStop(ax.dtick, stop.dtickrange, convertToMs)) {
1544-
return acc;
1545-
}
1546-
if(!acc) {
1547-
return stop;
1548-
} else {
1549-
return getRangeWidth(stop.dtickrange, convertToMs) > getRangeWidth(acc.dtickrange, convertToMs) ? stop : acc;
1550-
}
1551-
}, null);
1542+
tickstop = ax.tickformatstops.find(function(stop) {
1543+
return isProperStop(ax.dtick, stop.dtickrange, convertToMs)
1544+
});
15521545
break;
15531546
}
15541547
case 'linear': {
1555-
tickstop = ax.tickformatstops.reduce(function(acc, stop) {
1556-
if(!isProperStop(ax.dtick, stop.dtickrange)) {
1557-
return acc;
1558-
}
1559-
if(!acc) {
1560-
return stop;
1561-
} else {
1562-
return getRangeWidth(stop.dtickrange) > getRangeWidth(acc.dtickrange) ? stop : acc;
1563-
}
1564-
}, null);
1548+
tickstop = ax.tickformatstops.find(function(stop) {
1549+
return isProperStop(ax.dtick, stop.dtickrange, convertToMs)
1550+
});
15651551
break;
15661552
}
15671553
case 'log': {
1568-
tickstop = ax.tickformatstops.filter(function(stop) {
1554+
tickstop = ax.tickformatstops.find(function(stop) {
15691555
var left = stop.dtickrange[0], right = stop.dtickrange[1];
15701556
var isLeftDtickNull = left === null;
15711557
var isRightDtickNull = right === null;
15721558
var isDtickInRangeLeft = compareLogTicks(ax.dtick, left) >= 0;
15731559
var isDtickInRangeRight = compareLogTicks(ax.dtick, right) <= 0;
15741560
return (isLeftDtickNull || isDtickInRangeLeft) && (isRightDtickNull || isDtickInRangeRight);
1575-
})[0];
1561+
});
15761562
break;
15771563
}
15781564
default:

0 commit comments

Comments
 (0)