1 | "use strict";
|
2 |
|
3 |
|
4 | Object.defineProperty(exports, "__esModule", { value: true });
|
5 | exports.d3LinearNice = void 0;
|
6 | const ticks_1 = require("./ticks");
|
7 | const d3LinearNice = (min, max, count = 5) => {
|
8 | const d = [min, max];
|
9 | let i0 = 0;
|
10 | let i1 = d.length - 1;
|
11 | let start = d[i0];
|
12 | let stop = d[i1];
|
13 | let step;
|
14 | if (stop < start) {
|
15 | [start, stop] = [stop, start];
|
16 | [i0, i1] = [i1, i0];
|
17 | }
|
18 | step = (0, ticks_1.tickIncrement)(start, stop, count);
|
19 | if (step > 0) {
|
20 | start = Math.floor(start / step) * step;
|
21 | stop = Math.ceil(stop / step) * step;
|
22 | step = (0, ticks_1.tickIncrement)(start, stop, count);
|
23 | }
|
24 | else if (step < 0) {
|
25 | start = Math.ceil(start * step) / step;
|
26 | stop = Math.floor(stop * step) / step;
|
27 | step = (0, ticks_1.tickIncrement)(start, stop, count);
|
28 | }
|
29 | if (step > 0) {
|
30 | d[i0] = Math.floor(start / step) * step;
|
31 | d[i1] = Math.ceil(stop / step) * step;
|
32 | }
|
33 | else if (step < 0) {
|
34 | d[i0] = Math.ceil(start * step) / step;
|
35 | d[i1] = Math.floor(stop * step) / step;
|
36 | }
|
37 | return d;
|
38 | };
|
39 | exports.d3LinearNice = d3LinearNice;
|
40 |
|
\ | No newline at end of file |