Skip to content

Commit fa07cc5

Browse files
committed
create makeTransTickLabelFn and handle period case inside it
1 parent ee2d648 commit fa07cc5

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/plots/cartesian/axes.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,9 +2043,7 @@ axes.drawOne = function(gd, ax, opts) {
20432043
if(!ax.visible) return;
20442044

20452045
var transTickFn = axes.makeTransTickFn(ax);
2046-
var transTickLabelFn = ax.ticklabelmode === 'period' ?
2047-
axes.makeTransPeriodFn(ax) :
2048-
axes.makeTransTickFn(ax);
2046+
var transTickLabelFn = axes.makeTransTickLabelFn(ax);
20492047

20502048
var tickVals;
20512049
// We remove zero lines, grid lines, and inside ticks if they're within 1px of the end
@@ -2473,15 +2471,19 @@ axes.getTickSigns = function(ax) {
24732471
axes.makeTransTickFn = function(ax) {
24742472
var axLetter = ax._id.charAt(0);
24752473
var offset = ax._offset;
2474+
24762475
return axLetter === 'x' ?
24772476
function(d) { return strTranslate(offset + ax.l2p(d.x), 0); } :
24782477
function(d) { return strTranslate(0, offset + ax.l2p(d.x)); };
24792478
};
24802479

2481-
axes.makeTransPeriodFn = function(ax) {
2480+
axes.makeTransTickLabelFn = function(ax) {
24822481
var axLetter = ax._id.charAt(0);
24832482
var offset = ax._offset;
2484-
return axLetter === 'x' ?
2483+
var isX = axLetter === 'x';
2484+
2485+
if(ax.ticklabelmode === 'period') {
2486+
return isX ?
24852487
function(d) {
24862488
return strTranslate(
24872489
offset + ax.l2p(getPeriodX(d)),
@@ -2494,6 +2496,9 @@ axes.makeTransPeriodFn = function(ax) {
24942496
offset + ax.l2p(getPeriodX(d))
24952497
);
24962498
};
2499+
}
2500+
2501+
return axes.makeTransTickFn(ax);
24972502
};
24982503

24992504
function getPeriodX(d) {

0 commit comments

Comments
 (0)