Skip to content

Commit

Permalink
revert style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Jan 18, 2023
1 parent 763ba79 commit 3293873
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/ticks.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const e10 = Math.sqrt(50),
var e10 = Math.sqrt(50),
e5 = Math.sqrt(10),
e2 = Math.sqrt(2);

function tickSpec(start, stop, count) {
const step = (stop - start) / Math.max(0, count),
var step = (stop - start) / Math.max(0, count),
power = Math.floor(Math.log(step) / Math.LN10),
error = step / Math.pow(10, power);
if (power >= 0) {
const step = (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power);
let step = (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power);
let r0 = Math.round(start / step), r1 = Math.round(stop / step);
if (r0 * step < start) ++r0;
if (r1 * step > stop) --r1;
if (r1 < r0 && 0.5 <= count && count < 2) return tickSpec(start, stop, count * 2);
return r0 > r1 ? [r0, r1, 0] : [r0, r1, step];
} else {
const step = Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
let step = Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
let r0 = Math.round(start * step), r1 = Math.round(stop * step);
if (r0 / step < start) ++r0;
if (r1 / step > stop) --r1;
Expand All @@ -24,7 +24,7 @@ function tickSpec(start, stop, count) {
}

export default function ticks(start, stop, count) {
let reverse,
var reverse,
i = -1,
n,
ticks,
Expand Down Expand Up @@ -60,9 +60,9 @@ export function tickIncrement(start, stop, count) {
}

export function tickStep(start, stop, count) {
let step0 = Math.abs(stop - start) / Math.max(0, count);
let step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10));
const error = step0 / step1;
var step0 = Math.abs(stop - start) / Math.max(0, count),
step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
error = step0 / step1;
if (error >= e10) step1 *= 10;
else if (error >= e5) step1 *= 5;
else if (error >= e2) step1 *= 2;
Expand Down

0 comments on commit 3293873

Please sign in to comment.