Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exact log ticks #253

Merged
merged 2 commits into from
Sep 19, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
let/const
(see also #212)
  • Loading branch information
Fil authored and mbostock committed Sep 19, 2021
commit 98373ec169d4b03d39401d97493bfe36fd36e4f9
32 changes: 16 additions & 16 deletions src/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ function reflect(f) {
}

export function loggish(transform) {
let scale = transform(transformLog, transformExp),
domain = scale.domain,
base = 10,
logs,
pows;
const scale = transform(transformLog, transformExp);
const domain = scale.domain;
let base = 10;
let logs;
let pows;

function rescale() {
logs = logp(base), pows = powp(base);
Expand All @@ -72,19 +72,19 @@ export function loggish(transform) {
};

scale.ticks = count => {
let d = domain(),
u = d[0],
v = d[d.length - 1],
r = v < u;
const d = domain();
let u = d[0];
let v = d[d.length - 1];
const r = v < u;

if (r) ([u, v] = [v, u]);

let i = logs(u),
j = logs(v),
k,
t,
n = count == null ? 10 : +count,
z = [];
let i = logs(u);
let j = logs(v);
let k;
let t;
const n = count == null ? 10 : +count;
let z = [];

if (!(base % 1) && j - i < n) {
i = Math.floor(i), j = Math.ceil(j);
Expand Down Expand Up @@ -119,7 +119,7 @@ export function loggish(transform) {
specifier = format(specifier);
}
if (count === Infinity) return specifier;
let k = Math.max(1, base * count / scale.ticks().length); // TODO fast estimate?
const k = Math.max(1, base * count / scale.ticks().length); // TODO fast estimate?
return d => {
let i = d / pows(Math.round(logs(d)), 1);
if (i * base < base - 0.5) i *= base;
Expand Down