source: node_modules/d3-array/src/nice.js@ e4c61dd

Last change on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 535 bytes
Line 
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}
Note: See TracBrowser for help on using the repository browser.