MCPcopy Create free account
hub / github.com/d3/d3-array / nice

Function nice

src/nice.js:3–18  ·  view source on GitHub ↗
(start, stop, count)

Source from the content-addressed store, hash-verified

1import {tickIncrement} from "./ticks.js";
2
3export default function nice(start, stop, count) {
4 let prestep;
5 while (true) {
6 const step = tickIncrement(start, stop, count);
7 if (step === prestep || step === 0 || !isFinite(step)) {
8 return [start, stop];
9 } else if (step > 0) {
10 start = Math.floor(start / step) * step;
11 stop = Math.ceil(stop / step) * step;
12 } else if (step < 0) {
13 start = Math.ceil(start * step) / step;
14 stop = Math.floor(stop * step) / step;
15 }
16 prestep = step;
17 }
18}

Callers 2

nice-test.jsFile · 0.90
histogramFunction · 0.85

Calls 1

tickIncrementFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…