1 | import { $ as constant, a0 as interpolateNumber, a1 as color, a2 as interpolateRgb, a3 as interpolateString } from "./mermaid-dcacb631.js";
|
2 | import { i as initRange } from "./init-cc95ec8e.js";
|
3 | function ascending(a, b) {
|
4 | return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
5 | }
|
6 | function descending(a, b) {
|
7 | return a == null || b == null ? NaN : b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
|
8 | }
|
9 | function bisector(f) {
|
10 | let compare1, compare2, delta;
|
11 | if (f.length !== 2) {
|
12 | compare1 = ascending;
|
13 | compare2 = (d, x) => ascending(f(d), x);
|
14 | delta = (d, x) => f(d) - x;
|
15 | } else {
|
16 | compare1 = f === ascending || f === descending ? f : zero;
|
17 | compare2 = f;
|
18 | delta = f;
|
19 | }
|
20 | function left(a, x, lo = 0, hi = a.length) {
|
21 | if (lo < hi) {
|
22 | if (compare1(x, x) !== 0)
|
23 | return hi;
|
24 | do {
|
25 | const mid = lo + hi >>> 1;
|
26 | if (compare2(a[mid], x) < 0)
|
27 | lo = mid + 1;
|
28 | else
|
29 | hi = mid;
|
30 | } while (lo < hi);
|
31 | }
|
32 | return lo;
|
33 | }
|
34 | function right(a, x, lo = 0, hi = a.length) {
|
35 | if (lo < hi) {
|
36 | if (compare1(x, x) !== 0)
|
37 | return hi;
|
38 | do {
|
39 | const mid = lo + hi >>> 1;
|
40 | if (compare2(a[mid], x) <= 0)
|
41 | lo = mid + 1;
|
42 | else
|
43 | hi = mid;
|
44 | } while (lo < hi);
|
45 | }
|
46 | return lo;
|
47 | }
|
48 | function center(a, x, lo = 0, hi = a.length) {
|
49 | const i = left(a, x, lo, hi - 1);
|
50 | return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;
|
51 | }
|
52 | return { left, center, right };
|
53 | }
|
54 | function zero() {
|
55 | return 0;
|
56 | }
|
57 | function number$1(x) {
|
58 | return x === null ? NaN : +x;
|
59 | }
|
60 | const ascendingBisect = bisector(ascending);
|
61 | const bisectRight = ascendingBisect.right;
|
62 | bisector(number$1).center;
|
63 | const bisect = bisectRight;
|
64 | const e10 = Math.sqrt(50), e5 = Math.sqrt(10), e2 = Math.sqrt(2);
|
65 | function tickSpec(start, stop, count) {
|
66 | const step = (stop - start) / Math.max(0, count), power = Math.floor(Math.log10(step)), error = step / Math.pow(10, power), factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1;
|
67 | let i1, i2, inc;
|
68 | if (power < 0) {
|
69 | inc = Math.pow(10, -power) / factor;
|
70 | i1 = Math.round(start * inc);
|
71 | i2 = Math.round(stop * inc);
|
72 | if (i1 / inc < start)
|
73 | ++i1;
|
74 | if (i2 / inc > stop)
|
75 | --i2;
|
76 | inc = -inc;
|
77 | } else {
|
78 | inc = Math.pow(10, power) * factor;
|
79 | i1 = Math.round(start / inc);
|
80 | i2 = Math.round(stop / inc);
|
81 | if (i1 * inc < start)
|
82 | ++i1;
|
83 | if (i2 * inc > stop)
|
84 | --i2;
|
85 | }
|
86 | if (i2 < i1 && 0.5 <= count && count < 2)
|
87 | return tickSpec(start, stop, count * 2);
|
88 | return [i1, i2, inc];
|
89 | }
|
90 | function ticks(start, stop, count) {
|
91 | stop = +stop, start = +start, count = +count;
|
92 | if (!(count > 0))
|
93 | return [];
|
94 | if (start === stop)
|
95 | return [start];
|
96 | const reverse = stop < start, [i1, i2, inc] = reverse ? tickSpec(stop, start, count) : tickSpec(start, stop, count);
|
97 | if (!(i2 >= i1))
|
98 | return [];
|
99 | const n = i2 - i1 + 1, ticks2 = new Array(n);
|
100 | if (reverse) {
|
101 | if (inc < 0)
|
102 | for (let i = 0; i < n; ++i)
|
103 | ticks2[i] = (i2 - i) / -inc;
|
104 | else
|
105 | for (let i = 0; i < n; ++i)
|
106 | ticks2[i] = (i2 - i) * inc;
|
107 | } else {
|
108 | if (inc < 0)
|
109 | for (let i = 0; i < n; ++i)
|
110 | ticks2[i] = (i1 + i) / -inc;
|
111 | else
|
112 | for (let i = 0; i < n; ++i)
|
113 | ticks2[i] = (i1 + i) * inc;
|
114 | }
|
115 | return ticks2;
|
116 | }
|
117 | function tickIncrement(start, stop, count) {
|
118 | stop = +stop, start = +start, count = +count;
|
119 | return tickSpec(start, stop, count)[2];
|
120 | }
|
121 | function tickStep(start, stop, count) {
|
122 | stop = +stop, start = +start, count = +count;
|
123 | const reverse = stop < start, inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count);
|
124 | return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc);
|
125 | }
|
126 | function numberArray(a, b) {
|
127 | if (!b)
|
128 | b = [];
|
129 | var n = a ? Math.min(b.length, a.length) : 0, c = b.slice(), i;
|
130 | return function(t) {
|
131 | for (i = 0; i < n; ++i)
|
132 | c[i] = a[i] * (1 - t) + b[i] * t;
|
133 | return c;
|
134 | };
|
135 | }
|
136 | function isNumberArray(x) {
|
137 | return ArrayBuffer.isView(x) && !(x instanceof DataView);
|
138 | }
|
139 | function genericArray(a, b) {
|
140 | var nb = b ? b.length : 0, na = a ? Math.min(nb, a.length) : 0, x = new Array(na), c = new Array(nb), i;
|
141 | for (i = 0; i < na; ++i)
|
142 | x[i] = interpolate(a[i], b[i]);
|
143 | for (; i < nb; ++i)
|
144 | c[i] = b[i];
|
145 | return function(t) {
|
146 | for (i = 0; i < na; ++i)
|
147 | c[i] = x[i](t);
|
148 | return c;
|
149 | };
|
150 | }
|
151 | function date(a, b) {
|
152 | var d = new Date();
|
153 | return a = +a, b = +b, function(t) {
|
154 | return d.setTime(a * (1 - t) + b * t), d;
|
155 | };
|
156 | }
|
157 | function object(a, b) {
|
158 | var i = {}, c = {}, k;
|
159 | if (a === null || typeof a !== "object")
|
160 | a = {};
|
161 | if (b === null || typeof b !== "object")
|
162 | b = {};
|
163 | for (k in b) {
|
164 | if (k in a) {
|
165 | i[k] = interpolate(a[k], b[k]);
|
166 | } else {
|
167 | c[k] = b[k];
|
168 | }
|
169 | }
|
170 | return function(t) {
|
171 | for (k in i)
|
172 | c[k] = i[k](t);
|
173 | return c;
|
174 | };
|
175 | }
|
176 | function interpolate(a, b) {
|
177 | var t = typeof b, c;
|
178 | return b == null || t === "boolean" ? constant(b) : (t === "number" ? interpolateNumber : t === "string" ? (c = color(b)) ? (b = c, interpolateRgb) : interpolateString : b instanceof color ? interpolateRgb : b instanceof Date ? date : isNumberArray(b) ? numberArray : Array.isArray(b) ? genericArray : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object : interpolateNumber)(a, b);
|
179 | }
|
180 | function interpolateRound(a, b) {
|
181 | return a = +a, b = +b, function(t) {
|
182 | return Math.round(a * (1 - t) + b * t);
|
183 | };
|
184 | }
|
185 | function formatDecimal(x) {
|
186 | return Math.abs(x = Math.round(x)) >= 1e21 ? x.toLocaleString("en").replace(/,/g, "") : x.toString(10);
|
187 | }
|
188 | function formatDecimalParts(x, p) {
|
189 | if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0)
|
190 | return null;
|
191 | var i, coefficient = x.slice(0, i);
|
192 | return [
|
193 | coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
|
194 | +x.slice(i + 1)
|
195 | ];
|
196 | }
|
197 | function exponent(x) {
|
198 | return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN;
|
199 | }
|
200 | function formatGroup(grouping, thousands) {
|
201 | return function(value, width) {
|
202 | var i = value.length, t = [], j = 0, g = grouping[0], length = 0;
|
203 | while (i > 0 && g > 0) {
|
204 | if (length + g + 1 > width)
|
205 | g = Math.max(1, width - length);
|
206 | t.push(value.substring(i -= g, i + g));
|
207 | if ((length += g + 1) > width)
|
208 | break;
|
209 | g = grouping[j = (j + 1) % grouping.length];
|
210 | }
|
211 | return t.reverse().join(thousands);
|
212 | };
|
213 | }
|
214 | function formatNumerals(numerals) {
|
215 | return function(value) {
|
216 | return value.replace(/[0-9]/g, function(i) {
|
217 | return numerals[+i];
|
218 | });
|
219 | };
|
220 | }
|
221 | var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
|
222 | function formatSpecifier(specifier) {
|
223 | if (!(match = re.exec(specifier)))
|
224 | throw new Error("invalid format: " + specifier);
|
225 | var match;
|
226 | return new FormatSpecifier({
|
227 | fill: match[1],
|
228 | align: match[2],
|
229 | sign: match[3],
|
230 | symbol: match[4],
|
231 | zero: match[5],
|
232 | width: match[6],
|
233 | comma: match[7],
|
234 | precision: match[8] && match[8].slice(1),
|
235 | trim: match[9],
|
236 | type: match[10]
|
237 | });
|
238 | }
|
239 | formatSpecifier.prototype = FormatSpecifier.prototype;
|
240 | function FormatSpecifier(specifier) {
|
241 | this.fill = specifier.fill === void 0 ? " " : specifier.fill + "";
|
242 | this.align = specifier.align === void 0 ? ">" : specifier.align + "";
|
243 | this.sign = specifier.sign === void 0 ? "-" : specifier.sign + "";
|
244 | this.symbol = specifier.symbol === void 0 ? "" : specifier.symbol + "";
|
245 | this.zero = !!specifier.zero;
|
246 | this.width = specifier.width === void 0 ? void 0 : +specifier.width;
|
247 | this.comma = !!specifier.comma;
|
248 | this.precision = specifier.precision === void 0 ? void 0 : +specifier.precision;
|
249 | this.trim = !!specifier.trim;
|
250 | this.type = specifier.type === void 0 ? "" : specifier.type + "";
|
251 | }
|
252 | FormatSpecifier.prototype.toString = function() {
|
253 | return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
|
254 | };
|
255 | function formatTrim(s) {
|
256 | out:
|
257 | for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
|
258 | switch (s[i]) {
|
259 | case ".":
|
260 | i0 = i1 = i;
|
261 | break;
|
262 | case "0":
|
263 | if (i0 === 0)
|
264 | i0 = i;
|
265 | i1 = i;
|
266 | break;
|
267 | default:
|
268 | if (!+s[i])
|
269 | break out;
|
270 | if (i0 > 0)
|
271 | i0 = 0;
|
272 | break;
|
273 | }
|
274 | }
|
275 | return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
|
276 | }
|
277 | var prefixExponent;
|
278 | function formatPrefixAuto(x, p) {
|
279 | var d = formatDecimalParts(x, p);
|
280 | if (!d)
|
281 | return x + "";
|
282 | var coefficient = d[0], exponent2 = d[1], i = exponent2 - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent2 / 3))) * 3) + 1, n = coefficient.length;
|
283 | return i === n ? coefficient : i > n ? coefficient + new Array(i - n + 1).join("0") : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) : "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0];
|
284 | }
|
285 | function formatRounded(x, p) {
|
286 | var d = formatDecimalParts(x, p);
|
287 | if (!d)
|
288 | return x + "";
|
289 | var coefficient = d[0], exponent2 = d[1];
|
290 | return exponent2 < 0 ? "0." + new Array(-exponent2).join("0") + coefficient : coefficient.length > exponent2 + 1 ? coefficient.slice(0, exponent2 + 1) + "." + coefficient.slice(exponent2 + 1) : coefficient + new Array(exponent2 - coefficient.length + 2).join("0");
|
291 | }
|
292 | const formatTypes = {
|
293 | "%": (x, p) => (x * 100).toFixed(p),
|
294 | "b": (x) => Math.round(x).toString(2),
|
295 | "c": (x) => x + "",
|
296 | "d": formatDecimal,
|
297 | "e": (x, p) => x.toExponential(p),
|
298 | "f": (x, p) => x.toFixed(p),
|
299 | "g": (x, p) => x.toPrecision(p),
|
300 | "o": (x) => Math.round(x).toString(8),
|
301 | "p": (x, p) => formatRounded(x * 100, p),
|
302 | "r": formatRounded,
|
303 | "s": formatPrefixAuto,
|
304 | "X": (x) => Math.round(x).toString(16).toUpperCase(),
|
305 | "x": (x) => Math.round(x).toString(16)
|
306 | };
|
307 | function identity$1(x) {
|
308 | return x;
|
309 | }
|
310 | var map = Array.prototype.map, prefixes = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
|
311 | function formatLocale(locale2) {
|
312 | var group = locale2.grouping === void 0 || locale2.thousands === void 0 ? identity$1 : formatGroup(map.call(locale2.grouping, Number), locale2.thousands + ""), currencyPrefix = locale2.currency === void 0 ? "" : locale2.currency[0] + "", currencySuffix = locale2.currency === void 0 ? "" : locale2.currency[1] + "", decimal = locale2.decimal === void 0 ? "." : locale2.decimal + "", numerals = locale2.numerals === void 0 ? identity$1 : formatNumerals(map.call(locale2.numerals, String)), percent = locale2.percent === void 0 ? "%" : locale2.percent + "", minus = locale2.minus === void 0 ? "−" : locale2.minus + "", nan = locale2.nan === void 0 ? "NaN" : locale2.nan + "";
|
313 | function newFormat(specifier) {
|
314 | specifier = formatSpecifier(specifier);
|
315 | var fill = specifier.fill, align = specifier.align, sign = specifier.sign, symbol = specifier.symbol, zero2 = specifier.zero, width = specifier.width, comma = specifier.comma, precision = specifier.precision, trim = specifier.trim, type = specifier.type;
|
316 | if (type === "n")
|
317 | comma = true, type = "g";
|
318 | else if (!formatTypes[type])
|
319 | precision === void 0 && (precision = 12), trim = true, type = "g";
|
320 | if (zero2 || fill === "0" && align === "=")
|
321 | zero2 = true, fill = "0", align = "=";
|
322 | var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "";
|
323 | var formatType = formatTypes[type], maybeSuffix = /[defgprs%]/.test(type);
|
324 | precision = precision === void 0 ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision));
|
325 | function format2(value) {
|
326 | var valuePrefix = prefix, valueSuffix = suffix, i, n, c;
|
327 | if (type === "c") {
|
328 | valueSuffix = formatType(value) + valueSuffix;
|
329 | value = "";
|
330 | } else {
|
331 | value = +value;
|
332 | var valueNegative = value < 0 || 1 / value < 0;
|
333 | value = isNaN(value) ? nan : formatType(Math.abs(value), precision);
|
334 | if (trim)
|
335 | value = formatTrim(value);
|
336 | if (valueNegative && +value === 0 && sign !== "+")
|
337 | valueNegative = false;
|
338 | valuePrefix = (valueNegative ? sign === "(" ? sign : minus : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
|
339 | valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : "");
|
340 | if (maybeSuffix) {
|
341 | i = -1, n = value.length;
|
342 | while (++i < n) {
|
343 | if (c = value.charCodeAt(i), 48 > c || c > 57) {
|
344 | valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix;
|
345 | value = value.slice(0, i);
|
346 | break;
|
347 | }
|
348 | }
|
349 | }
|
350 | }
|
351 | if (comma && !zero2)
|
352 | value = group(value, Infinity);
|
353 | var length = valuePrefix.length + value.length + valueSuffix.length, padding = length < width ? new Array(width - length + 1).join(fill) : "";
|
354 | if (comma && zero2)
|
355 | value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
|
356 | switch (align) {
|
357 | case "<":
|
358 | value = valuePrefix + value + valueSuffix + padding;
|
359 | break;
|
360 | case "=":
|
361 | value = valuePrefix + padding + value + valueSuffix;
|
362 | break;
|
363 | case "^":
|
364 | value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length);
|
365 | break;
|
366 | default:
|
367 | value = padding + valuePrefix + value + valueSuffix;
|
368 | break;
|
369 | }
|
370 | return numerals(value);
|
371 | }
|
372 | format2.toString = function() {
|
373 | return specifier + "";
|
374 | };
|
375 | return format2;
|
376 | }
|
377 | function formatPrefix2(specifier, value) {
|
378 | var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)), e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3, k = Math.pow(10, -e), prefix = prefixes[8 + e / 3];
|
379 | return function(value2) {
|
380 | return f(k * value2) + prefix;
|
381 | };
|
382 | }
|
383 | return {
|
384 | format: newFormat,
|
385 | formatPrefix: formatPrefix2
|
386 | };
|
387 | }
|
388 | var locale;
|
389 | var format;
|
390 | var formatPrefix;
|
391 | defaultLocale({
|
392 | thousands: ",",
|
393 | grouping: [3],
|
394 | currency: ["$", ""]
|
395 | });
|
396 | function defaultLocale(definition) {
|
397 | locale = formatLocale(definition);
|
398 | format = locale.format;
|
399 | formatPrefix = locale.formatPrefix;
|
400 | return locale;
|
401 | }
|
402 | function precisionFixed(step) {
|
403 | return Math.max(0, -exponent(Math.abs(step)));
|
404 | }
|
405 | function precisionPrefix(step, value) {
|
406 | return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step)));
|
407 | }
|
408 | function precisionRound(step, max) {
|
409 | step = Math.abs(step), max = Math.abs(max) - step;
|
410 | return Math.max(0, exponent(max) - exponent(step)) + 1;
|
411 | }
|
412 | function constants(x) {
|
413 | return function() {
|
414 | return x;
|
415 | };
|
416 | }
|
417 | function number(x) {
|
418 | return +x;
|
419 | }
|
420 | var unit = [0, 1];
|
421 | function identity(x) {
|
422 | return x;
|
423 | }
|
424 | function normalize(a, b) {
|
425 | return (b -= a = +a) ? function(x) {
|
426 | return (x - a) / b;
|
427 | } : constants(isNaN(b) ? NaN : 0.5);
|
428 | }
|
429 | function clamper(a, b) {
|
430 | var t;
|
431 | if (a > b)
|
432 | t = a, a = b, b = t;
|
433 | return function(x) {
|
434 | return Math.max(a, Math.min(b, x));
|
435 | };
|
436 | }
|
437 | function bimap(domain, range, interpolate2) {
|
438 | var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
|
439 | if (d1 < d0)
|
440 | d0 = normalize(d1, d0), r0 = interpolate2(r1, r0);
|
441 | else
|
442 | d0 = normalize(d0, d1), r0 = interpolate2(r0, r1);
|
443 | return function(x) {
|
444 | return r0(d0(x));
|
445 | };
|
446 | }
|
447 | function polymap(domain, range, interpolate2) {
|
448 | var j = Math.min(domain.length, range.length) - 1, d = new Array(j), r = new Array(j), i = -1;
|
449 | if (domain[j] < domain[0]) {
|
450 | domain = domain.slice().reverse();
|
451 | range = range.slice().reverse();
|
452 | }
|
453 | while (++i < j) {
|
454 | d[i] = normalize(domain[i], domain[i + 1]);
|
455 | r[i] = interpolate2(range[i], range[i + 1]);
|
456 | }
|
457 | return function(x) {
|
458 | var i2 = bisect(domain, x, 1, j) - 1;
|
459 | return r[i2](d[i2](x));
|
460 | };
|
461 | }
|
462 | function copy(source, target) {
|
463 | return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown());
|
464 | }
|
465 | function transformer() {
|
466 | var domain = unit, range = unit, interpolate$1 = interpolate, transform, untransform, unknown, clamp = identity, piecewise, output, input;
|
467 | function rescale() {
|
468 | var n = Math.min(domain.length, range.length);
|
469 | if (clamp !== identity)
|
470 | clamp = clamper(domain[0], domain[n - 1]);
|
471 | piecewise = n > 2 ? polymap : bimap;
|
472 | output = input = null;
|
473 | return scale;
|
474 | }
|
475 | function scale(x) {
|
476 | return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate$1)))(transform(clamp(x)));
|
477 | }
|
478 | scale.invert = function(y) {
|
479 | return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y)));
|
480 | };
|
481 | scale.domain = function(_) {
|
482 | return arguments.length ? (domain = Array.from(_, number), rescale()) : domain.slice();
|
483 | };
|
484 | scale.range = function(_) {
|
485 | return arguments.length ? (range = Array.from(_), rescale()) : range.slice();
|
486 | };
|
487 | scale.rangeRound = function(_) {
|
488 | return range = Array.from(_), interpolate$1 = interpolateRound, rescale();
|
489 | };
|
490 | scale.clamp = function(_) {
|
491 | return arguments.length ? (clamp = _ ? true : identity, rescale()) : clamp !== identity;
|
492 | };
|
493 | scale.interpolate = function(_) {
|
494 | return arguments.length ? (interpolate$1 = _, rescale()) : interpolate$1;
|
495 | };
|
496 | scale.unknown = function(_) {
|
497 | return arguments.length ? (unknown = _, scale) : unknown;
|
498 | };
|
499 | return function(t, u) {
|
500 | transform = t, untransform = u;
|
501 | return rescale();
|
502 | };
|
503 | }
|
504 | function continuous() {
|
505 | return transformer()(identity, identity);
|
506 | }
|
507 | function tickFormat(start, stop, count, specifier) {
|
508 | var step = tickStep(start, stop, count), precision;
|
509 | specifier = formatSpecifier(specifier == null ? ",f" : specifier);
|
510 | switch (specifier.type) {
|
511 | case "s": {
|
512 | var value = Math.max(Math.abs(start), Math.abs(stop));
|
513 | if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value)))
|
514 | specifier.precision = precision;
|
515 | return formatPrefix(specifier, value);
|
516 | }
|
517 | case "":
|
518 | case "e":
|
519 | case "g":
|
520 | case "p":
|
521 | case "r": {
|
522 | if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop)))))
|
523 | specifier.precision = precision - (specifier.type === "e");
|
524 | break;
|
525 | }
|
526 | case "f":
|
527 | case "%": {
|
528 | if (specifier.precision == null && !isNaN(precision = precisionFixed(step)))
|
529 | specifier.precision = precision - (specifier.type === "%") * 2;
|
530 | break;
|
531 | }
|
532 | }
|
533 | return format(specifier);
|
534 | }
|
535 | function linearish(scale) {
|
536 | var domain = scale.domain;
|
537 | scale.ticks = function(count) {
|
538 | var d = domain();
|
539 | return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
|
540 | };
|
541 | scale.tickFormat = function(count, specifier) {
|
542 | var d = domain();
|
543 | return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier);
|
544 | };
|
545 | scale.nice = function(count) {
|
546 | if (count == null)
|
547 | count = 10;
|
548 | var d = domain();
|
549 | var i0 = 0;
|
550 | var i1 = d.length - 1;
|
551 | var start = d[i0];
|
552 | var stop = d[i1];
|
553 | var prestep;
|
554 | var step;
|
555 | var maxIter = 10;
|
556 | if (stop < start) {
|
557 | step = start, start = stop, stop = step;
|
558 | step = i0, i0 = i1, i1 = step;
|
559 | }
|
560 | while (maxIter-- > 0) {
|
561 | step = tickIncrement(start, stop, count);
|
562 | if (step === prestep) {
|
563 | d[i0] = start;
|
564 | d[i1] = stop;
|
565 | return domain(d);
|
566 | } else if (step > 0) {
|
567 | start = Math.floor(start / step) * step;
|
568 | stop = Math.ceil(stop / step) * step;
|
569 | } else if (step < 0) {
|
570 | start = Math.ceil(start * step) / step;
|
571 | stop = Math.floor(stop * step) / step;
|
572 | } else {
|
573 | break;
|
574 | }
|
575 | prestep = step;
|
576 | }
|
577 | return scale;
|
578 | };
|
579 | return scale;
|
580 | }
|
581 | function linear() {
|
582 | var scale = continuous();
|
583 | scale.copy = function() {
|
584 | return copy(scale, linear());
|
585 | };
|
586 | initRange.apply(scale, arguments);
|
587 | return linearish(scale);
|
588 | }
|
589 | export {
|
590 | copy as a,
|
591 | bisector as b,
|
592 | continuous as c,
|
593 | linear as l,
|
594 | tickStep as t
|
595 | };
|