Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b77b31

Browse files
committed
refactor - no need for else ifs in axes tickIncrement
1 parent ca193eb commit 6b77b31

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/plots/cartesian/axes.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -933,18 +933,20 @@ axes.tickIncrement = function(x, dtick, axrev, calendar) {
933933
if(tType === 'M') return Lib.incrementMonth(x, dtSigned, calendar);
934934

935935
// Log scales: Linear, Digits
936-
else if(tType === 'L') return Math.log(Math.pow(10, x) + dtSigned) / Math.LN10;
936+
if(tType === 'L') return Math.log(Math.pow(10, x) + dtSigned) / Math.LN10;
937937

938938
// log10 of 2,5,10, or all digits (logs just have to be
939939
// close enough to round)
940-
else if(tType === 'D') {
940+
if(tType === 'D') {
941941
var tickset = (dtick === 'D2') ? roundLog2 : roundLog1;
942942
var x2 = x + axSign * 0.01;
943943
var frac = Lib.roundUp(Lib.mod(x2, 1), tickset, axrev);
944944

945945
return Math.floor(x2) +
946946
Math.log(d3.round(Math.pow(10, frac), 1)) / Math.LN10;
947-
} else throw 'unrecognized dtick ' + String(dtick);
947+
}
948+
949+
throw 'unrecognized dtick ' + String(dtick);
948950
};
949951

950952
// calculate the first tick on an axis

0 commit comments

Comments
 (0)