UNPKG

1.08 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.d3Ticks = void 0;
4const utils_1 = require("../utils");
5const d3Ticks = (begin, end, count) => {
6 let n;
7 let ticks;
8 let start = begin;
9 let stop = end;
10 if (start === stop && count > 0) {
11 return [start];
12 }
13 let step = (0, utils_1.tickIncrement)(start, stop, count);
14 if (step === 0 || !Number.isFinite(step)) {
15 return [];
16 }
17 if (step > 0) {
18 start = Math.ceil(start / step);
19 stop = Math.floor(stop / step);
20 ticks = new Array((n = Math.ceil(stop - start + 1)));
21 for (let i = 0; i < n; i += 1) {
22 ticks[i] = (start + i) * step;
23 }
24 }
25 else {
26 step = -step;
27 start = Math.ceil(start * step);
28 stop = Math.floor(stop * step);
29 ticks = new Array((n = Math.ceil(stop - start + 1)));
30 for (let i = 0; i < n; i += 1) {
31 ticks[i] = (start + i) / step;
32 }
33 }
34 return ticks;
35};
36exports.d3Ticks = d3Ticks;
37//# sourceMappingURL=d3-ticks.js.map
\No newline at end of file