vvplot 0.1.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -3
- package/dist/style.css +0 -13
- package/dist/vvplot.d.ts +316 -0
- package/dist/vvplot.esm.js +20052 -0
- package/dist/vvplot.esm.min.js +25 -0
- package/dist/vvplot.global.js +20054 -0
- package/dist/vvplot.global.min.js +25 -0
- package/package.json +8 -9
- package/dist/Selection.js +0 -8159
- package/dist/break.d.ts +0 -1
- package/dist/break.js +0 -118
- package/dist/components.d.ts +0 -74
- package/dist/components.js +0 -27
- package/dist/index.d.ts +0 -74
- package/dist/index.js +0 -27
- package/dist/label.d.ts +0 -1
- package/dist/label.js +0 -151
- package/dist/scale.d.ts +0 -1
- package/dist/scale.js +0 -2973
- package/dist/theme.d.ts +0 -1
- package/dist/theme.js +0 -254
- package/dist/utils.js +0 -372
package/dist/scale.js
DELETED
|
@@ -1,2973 +0,0 @@
|
|
|
1
|
-
import { oob_squish_infinite, oob_squish_any, oob_censor } from "./utils.js";
|
|
2
|
-
function ascending$1(a, b) {
|
|
3
|
-
return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
4
|
-
}
|
|
5
|
-
function descending(a, b) {
|
|
6
|
-
return a == null || b == null ? NaN : b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
|
|
7
|
-
}
|
|
8
|
-
function bisector(f) {
|
|
9
|
-
let compare1, compare2, delta;
|
|
10
|
-
if (f.length !== 2) {
|
|
11
|
-
compare1 = ascending$1;
|
|
12
|
-
compare2 = (d, x) => ascending$1(f(d), x);
|
|
13
|
-
delta = (d, x) => f(d) - x;
|
|
14
|
-
} else {
|
|
15
|
-
compare1 = f === ascending$1 || f === descending ? f : zero$1;
|
|
16
|
-
compare2 = f;
|
|
17
|
-
delta = f;
|
|
18
|
-
}
|
|
19
|
-
function left(a, x, lo = 0, hi = a.length) {
|
|
20
|
-
if (lo < hi) {
|
|
21
|
-
if (compare1(x, x) !== 0) return hi;
|
|
22
|
-
do {
|
|
23
|
-
const mid = lo + hi >>> 1;
|
|
24
|
-
if (compare2(a[mid], x) < 0) lo = mid + 1;
|
|
25
|
-
else hi = mid;
|
|
26
|
-
} while (lo < hi);
|
|
27
|
-
}
|
|
28
|
-
return lo;
|
|
29
|
-
}
|
|
30
|
-
function right(a, x, lo = 0, hi = a.length) {
|
|
31
|
-
if (lo < hi) {
|
|
32
|
-
if (compare1(x, x) !== 0) return hi;
|
|
33
|
-
do {
|
|
34
|
-
const mid = lo + hi >>> 1;
|
|
35
|
-
if (compare2(a[mid], x) <= 0) lo = mid + 1;
|
|
36
|
-
else hi = mid;
|
|
37
|
-
} while (lo < hi);
|
|
38
|
-
}
|
|
39
|
-
return lo;
|
|
40
|
-
}
|
|
41
|
-
function center(a, x, lo = 0, hi = a.length) {
|
|
42
|
-
const i = left(a, x, lo, hi - 1);
|
|
43
|
-
return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;
|
|
44
|
-
}
|
|
45
|
-
return { left, center, right };
|
|
46
|
-
}
|
|
47
|
-
function zero$1() {
|
|
48
|
-
return 0;
|
|
49
|
-
}
|
|
50
|
-
function number$1(x) {
|
|
51
|
-
return x === null ? NaN : +x;
|
|
52
|
-
}
|
|
53
|
-
const ascendingBisect = bisector(ascending$1);
|
|
54
|
-
const bisectRight = ascendingBisect.right;
|
|
55
|
-
bisector(number$1).center;
|
|
56
|
-
const e10 = Math.sqrt(50), e5 = Math.sqrt(10), e2 = Math.sqrt(2);
|
|
57
|
-
function tickSpec(start2, stop, count) {
|
|
58
|
-
const step = (stop - start2) / 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;
|
|
59
|
-
let i1, i2, inc;
|
|
60
|
-
if (power < 0) {
|
|
61
|
-
inc = Math.pow(10, -power) / factor;
|
|
62
|
-
i1 = Math.round(start2 * inc);
|
|
63
|
-
i2 = Math.round(stop * inc);
|
|
64
|
-
if (i1 / inc < start2) ++i1;
|
|
65
|
-
if (i2 / inc > stop) --i2;
|
|
66
|
-
inc = -inc;
|
|
67
|
-
} else {
|
|
68
|
-
inc = Math.pow(10, power) * factor;
|
|
69
|
-
i1 = Math.round(start2 / inc);
|
|
70
|
-
i2 = Math.round(stop / inc);
|
|
71
|
-
if (i1 * inc < start2) ++i1;
|
|
72
|
-
if (i2 * inc > stop) --i2;
|
|
73
|
-
}
|
|
74
|
-
if (i2 < i1 && 0.5 <= count && count < 2) return tickSpec(start2, stop, count * 2);
|
|
75
|
-
return [i1, i2, inc];
|
|
76
|
-
}
|
|
77
|
-
function ticks(start2, stop, count) {
|
|
78
|
-
stop = +stop, start2 = +start2, count = +count;
|
|
79
|
-
if (!(count > 0)) return [];
|
|
80
|
-
if (start2 === stop) return [start2];
|
|
81
|
-
const reverse = stop < start2, [i1, i2, inc] = reverse ? tickSpec(stop, start2, count) : tickSpec(start2, stop, count);
|
|
82
|
-
if (!(i2 >= i1)) return [];
|
|
83
|
-
const n = i2 - i1 + 1, ticks2 = new Array(n);
|
|
84
|
-
if (reverse) {
|
|
85
|
-
if (inc < 0) for (let i = 0; i < n; ++i) ticks2[i] = (i2 - i) / -inc;
|
|
86
|
-
else for (let i = 0; i < n; ++i) ticks2[i] = (i2 - i) * inc;
|
|
87
|
-
} else {
|
|
88
|
-
if (inc < 0) for (let i = 0; i < n; ++i) ticks2[i] = (i1 + i) / -inc;
|
|
89
|
-
else for (let i = 0; i < n; ++i) ticks2[i] = (i1 + i) * inc;
|
|
90
|
-
}
|
|
91
|
-
return ticks2;
|
|
92
|
-
}
|
|
93
|
-
function tickIncrement(start2, stop, count) {
|
|
94
|
-
stop = +stop, start2 = +start2, count = +count;
|
|
95
|
-
return tickSpec(start2, stop, count)[2];
|
|
96
|
-
}
|
|
97
|
-
function tickStep(start2, stop, count) {
|
|
98
|
-
stop = +stop, start2 = +start2, count = +count;
|
|
99
|
-
const reverse = stop < start2, inc = reverse ? tickIncrement(stop, start2, count) : tickIncrement(start2, stop, count);
|
|
100
|
-
return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc);
|
|
101
|
-
}
|
|
102
|
-
var noop = { value: () => {
|
|
103
|
-
} };
|
|
104
|
-
function dispatch() {
|
|
105
|
-
for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) {
|
|
106
|
-
if (!(t = arguments[i] + "") || t in _ || /[\s.]/.test(t)) throw new Error("illegal type: " + t);
|
|
107
|
-
_[t] = [];
|
|
108
|
-
}
|
|
109
|
-
return new Dispatch(_);
|
|
110
|
-
}
|
|
111
|
-
function Dispatch(_) {
|
|
112
|
-
this._ = _;
|
|
113
|
-
}
|
|
114
|
-
function parseTypenames$1(typenames, types) {
|
|
115
|
-
return typenames.trim().split(/^|\s+/).map(function(t) {
|
|
116
|
-
var name = "", i = t.indexOf(".");
|
|
117
|
-
if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
|
|
118
|
-
if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t);
|
|
119
|
-
return { type: t, name };
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
Dispatch.prototype = dispatch.prototype = {
|
|
123
|
-
constructor: Dispatch,
|
|
124
|
-
on: function(typename, callback) {
|
|
125
|
-
var _ = this._, T = parseTypenames$1(typename + "", _), t, i = -1, n = T.length;
|
|
126
|
-
if (arguments.length < 2) {
|
|
127
|
-
while (++i < n) if ((t = (typename = T[i]).type) && (t = get$1(_[t], typename.name))) return t;
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback);
|
|
131
|
-
while (++i < n) {
|
|
132
|
-
if (t = (typename = T[i]).type) _[t] = set$1(_[t], typename.name, callback);
|
|
133
|
-
else if (callback == null) for (t in _) _[t] = set$1(_[t], typename.name, null);
|
|
134
|
-
}
|
|
135
|
-
return this;
|
|
136
|
-
},
|
|
137
|
-
copy: function() {
|
|
138
|
-
var copy2 = {}, _ = this._;
|
|
139
|
-
for (var t in _) copy2[t] = _[t].slice();
|
|
140
|
-
return new Dispatch(copy2);
|
|
141
|
-
},
|
|
142
|
-
call: function(type, that) {
|
|
143
|
-
if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2];
|
|
144
|
-
if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
|
|
145
|
-
for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
|
|
146
|
-
},
|
|
147
|
-
apply: function(type, that, args) {
|
|
148
|
-
if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
|
|
149
|
-
for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
function get$1(type, name) {
|
|
153
|
-
for (var i = 0, n = type.length, c; i < n; ++i) {
|
|
154
|
-
if ((c = type[i]).name === name) {
|
|
155
|
-
return c.value;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
function set$1(type, name, callback) {
|
|
160
|
-
for (var i = 0, n = type.length; i < n; ++i) {
|
|
161
|
-
if (type[i].name === name) {
|
|
162
|
-
type[i] = noop, type = type.slice(0, i).concat(type.slice(i + 1));
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (callback != null) type.push({ name, value: callback });
|
|
167
|
-
return type;
|
|
168
|
-
}
|
|
169
|
-
var xhtml = "http://www.w3.org/1999/xhtml";
|
|
170
|
-
const namespaces = {
|
|
171
|
-
svg: "http://www.w3.org/2000/svg",
|
|
172
|
-
xhtml,
|
|
173
|
-
xlink: "http://www.w3.org/1999/xlink",
|
|
174
|
-
xml: "http://www.w3.org/XML/1998/namespace",
|
|
175
|
-
xmlns: "http://www.w3.org/2000/xmlns/"
|
|
176
|
-
};
|
|
177
|
-
function namespace(name) {
|
|
178
|
-
var prefix = name += "", i = prefix.indexOf(":");
|
|
179
|
-
if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1);
|
|
180
|
-
return namespaces.hasOwnProperty(prefix) ? { space: namespaces[prefix], local: name } : name;
|
|
181
|
-
}
|
|
182
|
-
function creatorInherit(name) {
|
|
183
|
-
return function() {
|
|
184
|
-
var document2 = this.ownerDocument, uri = this.namespaceURI;
|
|
185
|
-
return uri === xhtml && document2.documentElement.namespaceURI === xhtml ? document2.createElement(name) : document2.createElementNS(uri, name);
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
function creatorFixed(fullname) {
|
|
189
|
-
return function() {
|
|
190
|
-
return this.ownerDocument.createElementNS(fullname.space, fullname.local);
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
function creator(name) {
|
|
194
|
-
var fullname = namespace(name);
|
|
195
|
-
return (fullname.local ? creatorFixed : creatorInherit)(fullname);
|
|
196
|
-
}
|
|
197
|
-
function none() {
|
|
198
|
-
}
|
|
199
|
-
function selector(selector2) {
|
|
200
|
-
return selector2 == null ? none : function() {
|
|
201
|
-
return this.querySelector(selector2);
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
function selection_select(select) {
|
|
205
|
-
if (typeof select !== "function") select = selector(select);
|
|
206
|
-
for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
|
|
207
|
-
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
|
|
208
|
-
if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
|
|
209
|
-
if ("__data__" in node) subnode.__data__ = node.__data__;
|
|
210
|
-
subgroup[i] = subnode;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return new Selection$1(subgroups, this._parents);
|
|
215
|
-
}
|
|
216
|
-
function array(x) {
|
|
217
|
-
return x == null ? [] : Array.isArray(x) ? x : Array.from(x);
|
|
218
|
-
}
|
|
219
|
-
function empty() {
|
|
220
|
-
return [];
|
|
221
|
-
}
|
|
222
|
-
function selectorAll(selector2) {
|
|
223
|
-
return selector2 == null ? empty : function() {
|
|
224
|
-
return this.querySelectorAll(selector2);
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
function arrayAll(select) {
|
|
228
|
-
return function() {
|
|
229
|
-
return array(select.apply(this, arguments));
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
function selection_selectAll(select) {
|
|
233
|
-
if (typeof select === "function") select = arrayAll(select);
|
|
234
|
-
else select = selectorAll(select);
|
|
235
|
-
for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
|
|
236
|
-
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
|
|
237
|
-
if (node = group[i]) {
|
|
238
|
-
subgroups.push(select.call(node, node.__data__, i, group));
|
|
239
|
-
parents.push(node);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
return new Selection$1(subgroups, parents);
|
|
244
|
-
}
|
|
245
|
-
function matcher(selector2) {
|
|
246
|
-
return function() {
|
|
247
|
-
return this.matches(selector2);
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
function childMatcher(selector2) {
|
|
251
|
-
return function(node) {
|
|
252
|
-
return node.matches(selector2);
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
var find = Array.prototype.find;
|
|
256
|
-
function childFind(match) {
|
|
257
|
-
return function() {
|
|
258
|
-
return find.call(this.children, match);
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
function childFirst() {
|
|
262
|
-
return this.firstElementChild;
|
|
263
|
-
}
|
|
264
|
-
function selection_selectChild(match) {
|
|
265
|
-
return this.select(match == null ? childFirst : childFind(typeof match === "function" ? match : childMatcher(match)));
|
|
266
|
-
}
|
|
267
|
-
var filter = Array.prototype.filter;
|
|
268
|
-
function children() {
|
|
269
|
-
return Array.from(this.children);
|
|
270
|
-
}
|
|
271
|
-
function childrenFilter(match) {
|
|
272
|
-
return function() {
|
|
273
|
-
return filter.call(this.children, match);
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
function selection_selectChildren(match) {
|
|
277
|
-
return this.selectAll(match == null ? children : childrenFilter(typeof match === "function" ? match : childMatcher(match)));
|
|
278
|
-
}
|
|
279
|
-
function selection_filter(match) {
|
|
280
|
-
if (typeof match !== "function") match = matcher(match);
|
|
281
|
-
for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
|
|
282
|
-
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
|
|
283
|
-
if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
|
|
284
|
-
subgroup.push(node);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return new Selection$1(subgroups, this._parents);
|
|
289
|
-
}
|
|
290
|
-
function sparse(update) {
|
|
291
|
-
return new Array(update.length);
|
|
292
|
-
}
|
|
293
|
-
function selection_enter() {
|
|
294
|
-
return new Selection$1(this._enter || this._groups.map(sparse), this._parents);
|
|
295
|
-
}
|
|
296
|
-
function EnterNode(parent, datum2) {
|
|
297
|
-
this.ownerDocument = parent.ownerDocument;
|
|
298
|
-
this.namespaceURI = parent.namespaceURI;
|
|
299
|
-
this._next = null;
|
|
300
|
-
this._parent = parent;
|
|
301
|
-
this.__data__ = datum2;
|
|
302
|
-
}
|
|
303
|
-
EnterNode.prototype = {
|
|
304
|
-
constructor: EnterNode,
|
|
305
|
-
appendChild: function(child) {
|
|
306
|
-
return this._parent.insertBefore(child, this._next);
|
|
307
|
-
},
|
|
308
|
-
insertBefore: function(child, next) {
|
|
309
|
-
return this._parent.insertBefore(child, next);
|
|
310
|
-
},
|
|
311
|
-
querySelector: function(selector2) {
|
|
312
|
-
return this._parent.querySelector(selector2);
|
|
313
|
-
},
|
|
314
|
-
querySelectorAll: function(selector2) {
|
|
315
|
-
return this._parent.querySelectorAll(selector2);
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
function constant$1(x) {
|
|
319
|
-
return function() {
|
|
320
|
-
return x;
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
function bindIndex(parent, group, enter, update, exit, data) {
|
|
324
|
-
var i = 0, node, groupLength = group.length, dataLength = data.length;
|
|
325
|
-
for (; i < dataLength; ++i) {
|
|
326
|
-
if (node = group[i]) {
|
|
327
|
-
node.__data__ = data[i];
|
|
328
|
-
update[i] = node;
|
|
329
|
-
} else {
|
|
330
|
-
enter[i] = new EnterNode(parent, data[i]);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
for (; i < groupLength; ++i) {
|
|
334
|
-
if (node = group[i]) {
|
|
335
|
-
exit[i] = node;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
function bindKey(parent, group, enter, update, exit, data, key) {
|
|
340
|
-
var i, node, nodeByKeyValue = /* @__PURE__ */ new Map(), groupLength = group.length, dataLength = data.length, keyValues = new Array(groupLength), keyValue;
|
|
341
|
-
for (i = 0; i < groupLength; ++i) {
|
|
342
|
-
if (node = group[i]) {
|
|
343
|
-
keyValues[i] = keyValue = key.call(node, node.__data__, i, group) + "";
|
|
344
|
-
if (nodeByKeyValue.has(keyValue)) {
|
|
345
|
-
exit[i] = node;
|
|
346
|
-
} else {
|
|
347
|
-
nodeByKeyValue.set(keyValue, node);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
for (i = 0; i < dataLength; ++i) {
|
|
352
|
-
keyValue = key.call(parent, data[i], i, data) + "";
|
|
353
|
-
if (node = nodeByKeyValue.get(keyValue)) {
|
|
354
|
-
update[i] = node;
|
|
355
|
-
node.__data__ = data[i];
|
|
356
|
-
nodeByKeyValue.delete(keyValue);
|
|
357
|
-
} else {
|
|
358
|
-
enter[i] = new EnterNode(parent, data[i]);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
for (i = 0; i < groupLength; ++i) {
|
|
362
|
-
if ((node = group[i]) && nodeByKeyValue.get(keyValues[i]) === node) {
|
|
363
|
-
exit[i] = node;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
function datum(node) {
|
|
368
|
-
return node.__data__;
|
|
369
|
-
}
|
|
370
|
-
function selection_data(value, key) {
|
|
371
|
-
if (!arguments.length) return Array.from(this, datum);
|
|
372
|
-
var bind = key ? bindKey : bindIndex, parents = this._parents, groups = this._groups;
|
|
373
|
-
if (typeof value !== "function") value = constant$1(value);
|
|
374
|
-
for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) {
|
|
375
|
-
var parent = parents[j], group = groups[j], groupLength = group.length, data = arraylike(value.call(parent, parent && parent.__data__, j, parents)), dataLength = data.length, enterGroup = enter[j] = new Array(dataLength), updateGroup = update[j] = new Array(dataLength), exitGroup = exit[j] = new Array(groupLength);
|
|
376
|
-
bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
|
|
377
|
-
for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
|
|
378
|
-
if (previous = enterGroup[i0]) {
|
|
379
|
-
if (i0 >= i1) i1 = i0 + 1;
|
|
380
|
-
while (!(next = updateGroup[i1]) && ++i1 < dataLength) ;
|
|
381
|
-
previous._next = next || null;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
update = new Selection$1(update, parents);
|
|
386
|
-
update._enter = enter;
|
|
387
|
-
update._exit = exit;
|
|
388
|
-
return update;
|
|
389
|
-
}
|
|
390
|
-
function arraylike(data) {
|
|
391
|
-
return typeof data === "object" && "length" in data ? data : Array.from(data);
|
|
392
|
-
}
|
|
393
|
-
function selection_exit() {
|
|
394
|
-
return new Selection$1(this._exit || this._groups.map(sparse), this._parents);
|
|
395
|
-
}
|
|
396
|
-
function selection_join(onenter, onupdate, onexit) {
|
|
397
|
-
var enter = this.enter(), update = this, exit = this.exit();
|
|
398
|
-
if (typeof onenter === "function") {
|
|
399
|
-
enter = onenter(enter);
|
|
400
|
-
if (enter) enter = enter.selection();
|
|
401
|
-
} else {
|
|
402
|
-
enter = enter.append(onenter + "");
|
|
403
|
-
}
|
|
404
|
-
if (onupdate != null) {
|
|
405
|
-
update = onupdate(update);
|
|
406
|
-
if (update) update = update.selection();
|
|
407
|
-
}
|
|
408
|
-
if (onexit == null) exit.remove();
|
|
409
|
-
else onexit(exit);
|
|
410
|
-
return enter && update ? enter.merge(update).order() : update;
|
|
411
|
-
}
|
|
412
|
-
function selection_merge(context) {
|
|
413
|
-
var selection2 = context.selection ? context.selection() : context;
|
|
414
|
-
for (var groups0 = this._groups, groups1 = selection2._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
|
|
415
|
-
for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
|
|
416
|
-
if (node = group0[i] || group1[i]) {
|
|
417
|
-
merge[i] = node;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
for (; j < m0; ++j) {
|
|
422
|
-
merges[j] = groups0[j];
|
|
423
|
-
}
|
|
424
|
-
return new Selection$1(merges, this._parents);
|
|
425
|
-
}
|
|
426
|
-
function selection_order() {
|
|
427
|
-
for (var groups = this._groups, j = -1, m = groups.length; ++j < m; ) {
|
|
428
|
-
for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0; ) {
|
|
429
|
-
if (node = group[i]) {
|
|
430
|
-
if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next);
|
|
431
|
-
next = node;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
return this;
|
|
436
|
-
}
|
|
437
|
-
function selection_sort(compare) {
|
|
438
|
-
if (!compare) compare = ascending;
|
|
439
|
-
function compareNode(a, b) {
|
|
440
|
-
return a && b ? compare(a.__data__, b.__data__) : !a - !b;
|
|
441
|
-
}
|
|
442
|
-
for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) {
|
|
443
|
-
for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) {
|
|
444
|
-
if (node = group[i]) {
|
|
445
|
-
sortgroup[i] = node;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
sortgroup.sort(compareNode);
|
|
449
|
-
}
|
|
450
|
-
return new Selection$1(sortgroups, this._parents).order();
|
|
451
|
-
}
|
|
452
|
-
function ascending(a, b) {
|
|
453
|
-
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
454
|
-
}
|
|
455
|
-
function selection_call() {
|
|
456
|
-
var callback = arguments[0];
|
|
457
|
-
arguments[0] = this;
|
|
458
|
-
callback.apply(null, arguments);
|
|
459
|
-
return this;
|
|
460
|
-
}
|
|
461
|
-
function selection_nodes() {
|
|
462
|
-
return Array.from(this);
|
|
463
|
-
}
|
|
464
|
-
function selection_node() {
|
|
465
|
-
for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
|
|
466
|
-
for (var group = groups[j], i = 0, n = group.length; i < n; ++i) {
|
|
467
|
-
var node = group[i];
|
|
468
|
-
if (node) return node;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
return null;
|
|
472
|
-
}
|
|
473
|
-
function selection_size() {
|
|
474
|
-
let size = 0;
|
|
475
|
-
for (const node of this) ++size;
|
|
476
|
-
return size;
|
|
477
|
-
}
|
|
478
|
-
function selection_empty() {
|
|
479
|
-
return !this.node();
|
|
480
|
-
}
|
|
481
|
-
function selection_each(callback) {
|
|
482
|
-
for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
|
|
483
|
-
for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) {
|
|
484
|
-
if (node = group[i]) callback.call(node, node.__data__, i, group);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
return this;
|
|
488
|
-
}
|
|
489
|
-
function attrRemove$1(name) {
|
|
490
|
-
return function() {
|
|
491
|
-
this.removeAttribute(name);
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
function attrRemoveNS$1(fullname) {
|
|
495
|
-
return function() {
|
|
496
|
-
this.removeAttributeNS(fullname.space, fullname.local);
|
|
497
|
-
};
|
|
498
|
-
}
|
|
499
|
-
function attrConstant$1(name, value) {
|
|
500
|
-
return function() {
|
|
501
|
-
this.setAttribute(name, value);
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
function attrConstantNS$1(fullname, value) {
|
|
505
|
-
return function() {
|
|
506
|
-
this.setAttributeNS(fullname.space, fullname.local, value);
|
|
507
|
-
};
|
|
508
|
-
}
|
|
509
|
-
function attrFunction$1(name, value) {
|
|
510
|
-
return function() {
|
|
511
|
-
var v = value.apply(this, arguments);
|
|
512
|
-
if (v == null) this.removeAttribute(name);
|
|
513
|
-
else this.setAttribute(name, v);
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
function attrFunctionNS$1(fullname, value) {
|
|
517
|
-
return function() {
|
|
518
|
-
var v = value.apply(this, arguments);
|
|
519
|
-
if (v == null) this.removeAttributeNS(fullname.space, fullname.local);
|
|
520
|
-
else this.setAttributeNS(fullname.space, fullname.local, v);
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
function selection_attr(name, value) {
|
|
524
|
-
var fullname = namespace(name);
|
|
525
|
-
if (arguments.length < 2) {
|
|
526
|
-
var node = this.node();
|
|
527
|
-
return fullname.local ? node.getAttributeNS(fullname.space, fullname.local) : node.getAttribute(fullname);
|
|
528
|
-
}
|
|
529
|
-
return this.each((value == null ? fullname.local ? attrRemoveNS$1 : attrRemove$1 : typeof value === "function" ? fullname.local ? attrFunctionNS$1 : attrFunction$1 : fullname.local ? attrConstantNS$1 : attrConstant$1)(fullname, value));
|
|
530
|
-
}
|
|
531
|
-
function defaultView(node) {
|
|
532
|
-
return node.ownerDocument && node.ownerDocument.defaultView || node.document && node || node.defaultView;
|
|
533
|
-
}
|
|
534
|
-
function styleRemove$1(name) {
|
|
535
|
-
return function() {
|
|
536
|
-
this.style.removeProperty(name);
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
function styleConstant$1(name, value, priority) {
|
|
540
|
-
return function() {
|
|
541
|
-
this.style.setProperty(name, value, priority);
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
function styleFunction$1(name, value, priority) {
|
|
545
|
-
return function() {
|
|
546
|
-
var v = value.apply(this, arguments);
|
|
547
|
-
if (v == null) this.style.removeProperty(name);
|
|
548
|
-
else this.style.setProperty(name, v, priority);
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
function selection_style(name, value, priority) {
|
|
552
|
-
return arguments.length > 1 ? this.each((value == null ? styleRemove$1 : typeof value === "function" ? styleFunction$1 : styleConstant$1)(name, value, priority == null ? "" : priority)) : styleValue(this.node(), name);
|
|
553
|
-
}
|
|
554
|
-
function styleValue(node, name) {
|
|
555
|
-
return node.style.getPropertyValue(name) || defaultView(node).getComputedStyle(node, null).getPropertyValue(name);
|
|
556
|
-
}
|
|
557
|
-
function propertyRemove(name) {
|
|
558
|
-
return function() {
|
|
559
|
-
delete this[name];
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
function propertyConstant(name, value) {
|
|
563
|
-
return function() {
|
|
564
|
-
this[name] = value;
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
function propertyFunction(name, value) {
|
|
568
|
-
return function() {
|
|
569
|
-
var v = value.apply(this, arguments);
|
|
570
|
-
if (v == null) delete this[name];
|
|
571
|
-
else this[name] = v;
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
function selection_property(name, value) {
|
|
575
|
-
return arguments.length > 1 ? this.each((value == null ? propertyRemove : typeof value === "function" ? propertyFunction : propertyConstant)(name, value)) : this.node()[name];
|
|
576
|
-
}
|
|
577
|
-
function classArray(string) {
|
|
578
|
-
return string.trim().split(/^|\s+/);
|
|
579
|
-
}
|
|
580
|
-
function classList(node) {
|
|
581
|
-
return node.classList || new ClassList(node);
|
|
582
|
-
}
|
|
583
|
-
function ClassList(node) {
|
|
584
|
-
this._node = node;
|
|
585
|
-
this._names = classArray(node.getAttribute("class") || "");
|
|
586
|
-
}
|
|
587
|
-
ClassList.prototype = {
|
|
588
|
-
add: function(name) {
|
|
589
|
-
var i = this._names.indexOf(name);
|
|
590
|
-
if (i < 0) {
|
|
591
|
-
this._names.push(name);
|
|
592
|
-
this._node.setAttribute("class", this._names.join(" "));
|
|
593
|
-
}
|
|
594
|
-
},
|
|
595
|
-
remove: function(name) {
|
|
596
|
-
var i = this._names.indexOf(name);
|
|
597
|
-
if (i >= 0) {
|
|
598
|
-
this._names.splice(i, 1);
|
|
599
|
-
this._node.setAttribute("class", this._names.join(" "));
|
|
600
|
-
}
|
|
601
|
-
},
|
|
602
|
-
contains: function(name) {
|
|
603
|
-
return this._names.indexOf(name) >= 0;
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
function classedAdd(node, names) {
|
|
607
|
-
var list = classList(node), i = -1, n = names.length;
|
|
608
|
-
while (++i < n) list.add(names[i]);
|
|
609
|
-
}
|
|
610
|
-
function classedRemove(node, names) {
|
|
611
|
-
var list = classList(node), i = -1, n = names.length;
|
|
612
|
-
while (++i < n) list.remove(names[i]);
|
|
613
|
-
}
|
|
614
|
-
function classedTrue(names) {
|
|
615
|
-
return function() {
|
|
616
|
-
classedAdd(this, names);
|
|
617
|
-
};
|
|
618
|
-
}
|
|
619
|
-
function classedFalse(names) {
|
|
620
|
-
return function() {
|
|
621
|
-
classedRemove(this, names);
|
|
622
|
-
};
|
|
623
|
-
}
|
|
624
|
-
function classedFunction(names, value) {
|
|
625
|
-
return function() {
|
|
626
|
-
(value.apply(this, arguments) ? classedAdd : classedRemove)(this, names);
|
|
627
|
-
};
|
|
628
|
-
}
|
|
629
|
-
function selection_classed(name, value) {
|
|
630
|
-
var names = classArray(name + "");
|
|
631
|
-
if (arguments.length < 2) {
|
|
632
|
-
var list = classList(this.node()), i = -1, n = names.length;
|
|
633
|
-
while (++i < n) if (!list.contains(names[i])) return false;
|
|
634
|
-
return true;
|
|
635
|
-
}
|
|
636
|
-
return this.each((typeof value === "function" ? classedFunction : value ? classedTrue : classedFalse)(names, value));
|
|
637
|
-
}
|
|
638
|
-
function textRemove() {
|
|
639
|
-
this.textContent = "";
|
|
640
|
-
}
|
|
641
|
-
function textConstant$1(value) {
|
|
642
|
-
return function() {
|
|
643
|
-
this.textContent = value;
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
function textFunction$1(value) {
|
|
647
|
-
return function() {
|
|
648
|
-
var v = value.apply(this, arguments);
|
|
649
|
-
this.textContent = v == null ? "" : v;
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
function selection_text(value) {
|
|
653
|
-
return arguments.length ? this.each(value == null ? textRemove : (typeof value === "function" ? textFunction$1 : textConstant$1)(value)) : this.node().textContent;
|
|
654
|
-
}
|
|
655
|
-
function htmlRemove() {
|
|
656
|
-
this.innerHTML = "";
|
|
657
|
-
}
|
|
658
|
-
function htmlConstant(value) {
|
|
659
|
-
return function() {
|
|
660
|
-
this.innerHTML = value;
|
|
661
|
-
};
|
|
662
|
-
}
|
|
663
|
-
function htmlFunction(value) {
|
|
664
|
-
return function() {
|
|
665
|
-
var v = value.apply(this, arguments);
|
|
666
|
-
this.innerHTML = v == null ? "" : v;
|
|
667
|
-
};
|
|
668
|
-
}
|
|
669
|
-
function selection_html(value) {
|
|
670
|
-
return arguments.length ? this.each(value == null ? htmlRemove : (typeof value === "function" ? htmlFunction : htmlConstant)(value)) : this.node().innerHTML;
|
|
671
|
-
}
|
|
672
|
-
function raise() {
|
|
673
|
-
if (this.nextSibling) this.parentNode.appendChild(this);
|
|
674
|
-
}
|
|
675
|
-
function selection_raise() {
|
|
676
|
-
return this.each(raise);
|
|
677
|
-
}
|
|
678
|
-
function lower() {
|
|
679
|
-
if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild);
|
|
680
|
-
}
|
|
681
|
-
function selection_lower() {
|
|
682
|
-
return this.each(lower);
|
|
683
|
-
}
|
|
684
|
-
function selection_append(name) {
|
|
685
|
-
var create2 = typeof name === "function" ? name : creator(name);
|
|
686
|
-
return this.select(function() {
|
|
687
|
-
return this.appendChild(create2.apply(this, arguments));
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
function constantNull() {
|
|
691
|
-
return null;
|
|
692
|
-
}
|
|
693
|
-
function selection_insert(name, before) {
|
|
694
|
-
var create2 = typeof name === "function" ? name : creator(name), select = before == null ? constantNull : typeof before === "function" ? before : selector(before);
|
|
695
|
-
return this.select(function() {
|
|
696
|
-
return this.insertBefore(create2.apply(this, arguments), select.apply(this, arguments) || null);
|
|
697
|
-
});
|
|
698
|
-
}
|
|
699
|
-
function remove() {
|
|
700
|
-
var parent = this.parentNode;
|
|
701
|
-
if (parent) parent.removeChild(this);
|
|
702
|
-
}
|
|
703
|
-
function selection_remove() {
|
|
704
|
-
return this.each(remove);
|
|
705
|
-
}
|
|
706
|
-
function selection_cloneShallow() {
|
|
707
|
-
var clone = this.cloneNode(false), parent = this.parentNode;
|
|
708
|
-
return parent ? parent.insertBefore(clone, this.nextSibling) : clone;
|
|
709
|
-
}
|
|
710
|
-
function selection_cloneDeep() {
|
|
711
|
-
var clone = this.cloneNode(true), parent = this.parentNode;
|
|
712
|
-
return parent ? parent.insertBefore(clone, this.nextSibling) : clone;
|
|
713
|
-
}
|
|
714
|
-
function selection_clone(deep) {
|
|
715
|
-
return this.select(deep ? selection_cloneDeep : selection_cloneShallow);
|
|
716
|
-
}
|
|
717
|
-
function selection_datum(value) {
|
|
718
|
-
return arguments.length ? this.property("__data__", value) : this.node().__data__;
|
|
719
|
-
}
|
|
720
|
-
function contextListener(listener) {
|
|
721
|
-
return function(event) {
|
|
722
|
-
listener.call(this, event, this.__data__);
|
|
723
|
-
};
|
|
724
|
-
}
|
|
725
|
-
function parseTypenames(typenames) {
|
|
726
|
-
return typenames.trim().split(/^|\s+/).map(function(t) {
|
|
727
|
-
var name = "", i = t.indexOf(".");
|
|
728
|
-
if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
|
|
729
|
-
return { type: t, name };
|
|
730
|
-
});
|
|
731
|
-
}
|
|
732
|
-
function onRemove(typename) {
|
|
733
|
-
return function() {
|
|
734
|
-
var on = this.__on;
|
|
735
|
-
if (!on) return;
|
|
736
|
-
for (var j = 0, i = -1, m = on.length, o; j < m; ++j) {
|
|
737
|
-
if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) {
|
|
738
|
-
this.removeEventListener(o.type, o.listener, o.options);
|
|
739
|
-
} else {
|
|
740
|
-
on[++i] = o;
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
if (++i) on.length = i;
|
|
744
|
-
else delete this.__on;
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
function onAdd(typename, value, options) {
|
|
748
|
-
return function() {
|
|
749
|
-
var on = this.__on, o, listener = contextListener(value);
|
|
750
|
-
if (on) for (var j = 0, m = on.length; j < m; ++j) {
|
|
751
|
-
if ((o = on[j]).type === typename.type && o.name === typename.name) {
|
|
752
|
-
this.removeEventListener(o.type, o.listener, o.options);
|
|
753
|
-
this.addEventListener(o.type, o.listener = listener, o.options = options);
|
|
754
|
-
o.value = value;
|
|
755
|
-
return;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
this.addEventListener(typename.type, listener, options);
|
|
759
|
-
o = { type: typename.type, name: typename.name, value, listener, options };
|
|
760
|
-
if (!on) this.__on = [o];
|
|
761
|
-
else on.push(o);
|
|
762
|
-
};
|
|
763
|
-
}
|
|
764
|
-
function selection_on(typename, value, options) {
|
|
765
|
-
var typenames = parseTypenames(typename + ""), i, n = typenames.length, t;
|
|
766
|
-
if (arguments.length < 2) {
|
|
767
|
-
var on = this.node().__on;
|
|
768
|
-
if (on) for (var j = 0, m = on.length, o; j < m; ++j) {
|
|
769
|
-
for (i = 0, o = on[j]; i < n; ++i) {
|
|
770
|
-
if ((t = typenames[i]).type === o.type && t.name === o.name) {
|
|
771
|
-
return o.value;
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
return;
|
|
776
|
-
}
|
|
777
|
-
on = value ? onAdd : onRemove;
|
|
778
|
-
for (i = 0; i < n; ++i) this.each(on(typenames[i], value, options));
|
|
779
|
-
return this;
|
|
780
|
-
}
|
|
781
|
-
function dispatchEvent(node, type, params) {
|
|
782
|
-
var window2 = defaultView(node), event = window2.CustomEvent;
|
|
783
|
-
if (typeof event === "function") {
|
|
784
|
-
event = new event(type, params);
|
|
785
|
-
} else {
|
|
786
|
-
event = window2.document.createEvent("Event");
|
|
787
|
-
if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
|
|
788
|
-
else event.initEvent(type, false, false);
|
|
789
|
-
}
|
|
790
|
-
node.dispatchEvent(event);
|
|
791
|
-
}
|
|
792
|
-
function dispatchConstant(type, params) {
|
|
793
|
-
return function() {
|
|
794
|
-
return dispatchEvent(this, type, params);
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
function dispatchFunction(type, params) {
|
|
798
|
-
return function() {
|
|
799
|
-
return dispatchEvent(this, type, params.apply(this, arguments));
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
function selection_dispatch(type, params) {
|
|
803
|
-
return this.each((typeof params === "function" ? dispatchFunction : dispatchConstant)(type, params));
|
|
804
|
-
}
|
|
805
|
-
function* selection_iterator() {
|
|
806
|
-
for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
|
|
807
|
-
for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) {
|
|
808
|
-
if (node = group[i]) yield node;
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
var root = [null];
|
|
813
|
-
function Selection$1(groups, parents) {
|
|
814
|
-
this._groups = groups;
|
|
815
|
-
this._parents = parents;
|
|
816
|
-
}
|
|
817
|
-
function selection() {
|
|
818
|
-
return new Selection$1([[document.documentElement]], root);
|
|
819
|
-
}
|
|
820
|
-
function selection_selection() {
|
|
821
|
-
return this;
|
|
822
|
-
}
|
|
823
|
-
Selection$1.prototype = selection.prototype = {
|
|
824
|
-
constructor: Selection$1,
|
|
825
|
-
select: selection_select,
|
|
826
|
-
selectAll: selection_selectAll,
|
|
827
|
-
selectChild: selection_selectChild,
|
|
828
|
-
selectChildren: selection_selectChildren,
|
|
829
|
-
filter: selection_filter,
|
|
830
|
-
data: selection_data,
|
|
831
|
-
enter: selection_enter,
|
|
832
|
-
exit: selection_exit,
|
|
833
|
-
join: selection_join,
|
|
834
|
-
merge: selection_merge,
|
|
835
|
-
selection: selection_selection,
|
|
836
|
-
order: selection_order,
|
|
837
|
-
sort: selection_sort,
|
|
838
|
-
call: selection_call,
|
|
839
|
-
nodes: selection_nodes,
|
|
840
|
-
node: selection_node,
|
|
841
|
-
size: selection_size,
|
|
842
|
-
empty: selection_empty,
|
|
843
|
-
each: selection_each,
|
|
844
|
-
attr: selection_attr,
|
|
845
|
-
style: selection_style,
|
|
846
|
-
property: selection_property,
|
|
847
|
-
classed: selection_classed,
|
|
848
|
-
text: selection_text,
|
|
849
|
-
html: selection_html,
|
|
850
|
-
raise: selection_raise,
|
|
851
|
-
lower: selection_lower,
|
|
852
|
-
append: selection_append,
|
|
853
|
-
insert: selection_insert,
|
|
854
|
-
remove: selection_remove,
|
|
855
|
-
clone: selection_clone,
|
|
856
|
-
datum: selection_datum,
|
|
857
|
-
on: selection_on,
|
|
858
|
-
dispatch: selection_dispatch,
|
|
859
|
-
[Symbol.iterator]: selection_iterator
|
|
860
|
-
};
|
|
861
|
-
function define(constructor, factory, prototype) {
|
|
862
|
-
constructor.prototype = factory.prototype = prototype;
|
|
863
|
-
prototype.constructor = constructor;
|
|
864
|
-
}
|
|
865
|
-
function extend(parent, definition) {
|
|
866
|
-
var prototype = Object.create(parent.prototype);
|
|
867
|
-
for (var key in definition) prototype[key] = definition[key];
|
|
868
|
-
return prototype;
|
|
869
|
-
}
|
|
870
|
-
function Color() {
|
|
871
|
-
}
|
|
872
|
-
var darker = 0.7;
|
|
873
|
-
var brighter = 1 / darker;
|
|
874
|
-
var reI = "\\s*([+-]?\\d+)\\s*", reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", reHex = /^#([0-9a-f]{3,8})$/, reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`), reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`), reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`), reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`), reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`), reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`);
|
|
875
|
-
var named = {
|
|
876
|
-
aliceblue: 15792383,
|
|
877
|
-
antiquewhite: 16444375,
|
|
878
|
-
aqua: 65535,
|
|
879
|
-
aquamarine: 8388564,
|
|
880
|
-
azure: 15794175,
|
|
881
|
-
beige: 16119260,
|
|
882
|
-
bisque: 16770244,
|
|
883
|
-
black: 0,
|
|
884
|
-
blanchedalmond: 16772045,
|
|
885
|
-
blue: 255,
|
|
886
|
-
blueviolet: 9055202,
|
|
887
|
-
brown: 10824234,
|
|
888
|
-
burlywood: 14596231,
|
|
889
|
-
cadetblue: 6266528,
|
|
890
|
-
chartreuse: 8388352,
|
|
891
|
-
chocolate: 13789470,
|
|
892
|
-
coral: 16744272,
|
|
893
|
-
cornflowerblue: 6591981,
|
|
894
|
-
cornsilk: 16775388,
|
|
895
|
-
crimson: 14423100,
|
|
896
|
-
cyan: 65535,
|
|
897
|
-
darkblue: 139,
|
|
898
|
-
darkcyan: 35723,
|
|
899
|
-
darkgoldenrod: 12092939,
|
|
900
|
-
darkgray: 11119017,
|
|
901
|
-
darkgreen: 25600,
|
|
902
|
-
darkgrey: 11119017,
|
|
903
|
-
darkkhaki: 12433259,
|
|
904
|
-
darkmagenta: 9109643,
|
|
905
|
-
darkolivegreen: 5597999,
|
|
906
|
-
darkorange: 16747520,
|
|
907
|
-
darkorchid: 10040012,
|
|
908
|
-
darkred: 9109504,
|
|
909
|
-
darksalmon: 15308410,
|
|
910
|
-
darkseagreen: 9419919,
|
|
911
|
-
darkslateblue: 4734347,
|
|
912
|
-
darkslategray: 3100495,
|
|
913
|
-
darkslategrey: 3100495,
|
|
914
|
-
darkturquoise: 52945,
|
|
915
|
-
darkviolet: 9699539,
|
|
916
|
-
deeppink: 16716947,
|
|
917
|
-
deepskyblue: 49151,
|
|
918
|
-
dimgray: 6908265,
|
|
919
|
-
dimgrey: 6908265,
|
|
920
|
-
dodgerblue: 2003199,
|
|
921
|
-
firebrick: 11674146,
|
|
922
|
-
floralwhite: 16775920,
|
|
923
|
-
forestgreen: 2263842,
|
|
924
|
-
fuchsia: 16711935,
|
|
925
|
-
gainsboro: 14474460,
|
|
926
|
-
ghostwhite: 16316671,
|
|
927
|
-
gold: 16766720,
|
|
928
|
-
goldenrod: 14329120,
|
|
929
|
-
gray: 8421504,
|
|
930
|
-
green: 32768,
|
|
931
|
-
greenyellow: 11403055,
|
|
932
|
-
grey: 8421504,
|
|
933
|
-
honeydew: 15794160,
|
|
934
|
-
hotpink: 16738740,
|
|
935
|
-
indianred: 13458524,
|
|
936
|
-
indigo: 4915330,
|
|
937
|
-
ivory: 16777200,
|
|
938
|
-
khaki: 15787660,
|
|
939
|
-
lavender: 15132410,
|
|
940
|
-
lavenderblush: 16773365,
|
|
941
|
-
lawngreen: 8190976,
|
|
942
|
-
lemonchiffon: 16775885,
|
|
943
|
-
lightblue: 11393254,
|
|
944
|
-
lightcoral: 15761536,
|
|
945
|
-
lightcyan: 14745599,
|
|
946
|
-
lightgoldenrodyellow: 16448210,
|
|
947
|
-
lightgray: 13882323,
|
|
948
|
-
lightgreen: 9498256,
|
|
949
|
-
lightgrey: 13882323,
|
|
950
|
-
lightpink: 16758465,
|
|
951
|
-
lightsalmon: 16752762,
|
|
952
|
-
lightseagreen: 2142890,
|
|
953
|
-
lightskyblue: 8900346,
|
|
954
|
-
lightslategray: 7833753,
|
|
955
|
-
lightslategrey: 7833753,
|
|
956
|
-
lightsteelblue: 11584734,
|
|
957
|
-
lightyellow: 16777184,
|
|
958
|
-
lime: 65280,
|
|
959
|
-
limegreen: 3329330,
|
|
960
|
-
linen: 16445670,
|
|
961
|
-
magenta: 16711935,
|
|
962
|
-
maroon: 8388608,
|
|
963
|
-
mediumaquamarine: 6737322,
|
|
964
|
-
mediumblue: 205,
|
|
965
|
-
mediumorchid: 12211667,
|
|
966
|
-
mediumpurple: 9662683,
|
|
967
|
-
mediumseagreen: 3978097,
|
|
968
|
-
mediumslateblue: 8087790,
|
|
969
|
-
mediumspringgreen: 64154,
|
|
970
|
-
mediumturquoise: 4772300,
|
|
971
|
-
mediumvioletred: 13047173,
|
|
972
|
-
midnightblue: 1644912,
|
|
973
|
-
mintcream: 16121850,
|
|
974
|
-
mistyrose: 16770273,
|
|
975
|
-
moccasin: 16770229,
|
|
976
|
-
navajowhite: 16768685,
|
|
977
|
-
navy: 128,
|
|
978
|
-
oldlace: 16643558,
|
|
979
|
-
olive: 8421376,
|
|
980
|
-
olivedrab: 7048739,
|
|
981
|
-
orange: 16753920,
|
|
982
|
-
orangered: 16729344,
|
|
983
|
-
orchid: 14315734,
|
|
984
|
-
palegoldenrod: 15657130,
|
|
985
|
-
palegreen: 10025880,
|
|
986
|
-
paleturquoise: 11529966,
|
|
987
|
-
palevioletred: 14381203,
|
|
988
|
-
papayawhip: 16773077,
|
|
989
|
-
peachpuff: 16767673,
|
|
990
|
-
peru: 13468991,
|
|
991
|
-
pink: 16761035,
|
|
992
|
-
plum: 14524637,
|
|
993
|
-
powderblue: 11591910,
|
|
994
|
-
purple: 8388736,
|
|
995
|
-
rebeccapurple: 6697881,
|
|
996
|
-
red: 16711680,
|
|
997
|
-
rosybrown: 12357519,
|
|
998
|
-
royalblue: 4286945,
|
|
999
|
-
saddlebrown: 9127187,
|
|
1000
|
-
salmon: 16416882,
|
|
1001
|
-
sandybrown: 16032864,
|
|
1002
|
-
seagreen: 3050327,
|
|
1003
|
-
seashell: 16774638,
|
|
1004
|
-
sienna: 10506797,
|
|
1005
|
-
silver: 12632256,
|
|
1006
|
-
skyblue: 8900331,
|
|
1007
|
-
slateblue: 6970061,
|
|
1008
|
-
slategray: 7372944,
|
|
1009
|
-
slategrey: 7372944,
|
|
1010
|
-
snow: 16775930,
|
|
1011
|
-
springgreen: 65407,
|
|
1012
|
-
steelblue: 4620980,
|
|
1013
|
-
tan: 13808780,
|
|
1014
|
-
teal: 32896,
|
|
1015
|
-
thistle: 14204888,
|
|
1016
|
-
tomato: 16737095,
|
|
1017
|
-
turquoise: 4251856,
|
|
1018
|
-
violet: 15631086,
|
|
1019
|
-
wheat: 16113331,
|
|
1020
|
-
white: 16777215,
|
|
1021
|
-
whitesmoke: 16119285,
|
|
1022
|
-
yellow: 16776960,
|
|
1023
|
-
yellowgreen: 10145074
|
|
1024
|
-
};
|
|
1025
|
-
define(Color, color, {
|
|
1026
|
-
copy(channels) {
|
|
1027
|
-
return Object.assign(new this.constructor(), this, channels);
|
|
1028
|
-
},
|
|
1029
|
-
displayable() {
|
|
1030
|
-
return this.rgb().displayable();
|
|
1031
|
-
},
|
|
1032
|
-
hex: color_formatHex,
|
|
1033
|
-
// Deprecated! Use color.formatHex.
|
|
1034
|
-
formatHex: color_formatHex,
|
|
1035
|
-
formatHex8: color_formatHex8,
|
|
1036
|
-
formatHsl: color_formatHsl,
|
|
1037
|
-
formatRgb: color_formatRgb,
|
|
1038
|
-
toString: color_formatRgb
|
|
1039
|
-
});
|
|
1040
|
-
function color_formatHex() {
|
|
1041
|
-
return this.rgb().formatHex();
|
|
1042
|
-
}
|
|
1043
|
-
function color_formatHex8() {
|
|
1044
|
-
return this.rgb().formatHex8();
|
|
1045
|
-
}
|
|
1046
|
-
function color_formatHsl() {
|
|
1047
|
-
return hslConvert(this).formatHsl();
|
|
1048
|
-
}
|
|
1049
|
-
function color_formatRgb() {
|
|
1050
|
-
return this.rgb().formatRgb();
|
|
1051
|
-
}
|
|
1052
|
-
function color(format2) {
|
|
1053
|
-
var m, l;
|
|
1054
|
-
format2 = (format2 + "").trim().toLowerCase();
|
|
1055
|
-
return (m = reHex.exec(format2)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) : l === 3 ? new Rgb(m >> 8 & 15 | m >> 4 & 240, m >> 4 & 15 | m & 240, (m & 15) << 4 | m & 15, 1) : l === 8 ? rgba(m >> 24 & 255, m >> 16 & 255, m >> 8 & 255, (m & 255) / 255) : l === 4 ? rgba(m >> 12 & 15 | m >> 8 & 240, m >> 8 & 15 | m >> 4 & 240, m >> 4 & 15 | m & 240, ((m & 15) << 4 | m & 15) / 255) : null) : (m = reRgbInteger.exec(format2)) ? new Rgb(m[1], m[2], m[3], 1) : (m = reRgbPercent.exec(format2)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) : (m = reRgbaInteger.exec(format2)) ? rgba(m[1], m[2], m[3], m[4]) : (m = reRgbaPercent.exec(format2)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) : (m = reHslPercent.exec(format2)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) : (m = reHslaPercent.exec(format2)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) : named.hasOwnProperty(format2) ? rgbn(named[format2]) : format2 === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null;
|
|
1056
|
-
}
|
|
1057
|
-
function rgbn(n) {
|
|
1058
|
-
return new Rgb(n >> 16 & 255, n >> 8 & 255, n & 255, 1);
|
|
1059
|
-
}
|
|
1060
|
-
function rgba(r, g, b, a) {
|
|
1061
|
-
if (a <= 0) r = g = b = NaN;
|
|
1062
|
-
return new Rgb(r, g, b, a);
|
|
1063
|
-
}
|
|
1064
|
-
function rgbConvert(o) {
|
|
1065
|
-
if (!(o instanceof Color)) o = color(o);
|
|
1066
|
-
if (!o) return new Rgb();
|
|
1067
|
-
o = o.rgb();
|
|
1068
|
-
return new Rgb(o.r, o.g, o.b, o.opacity);
|
|
1069
|
-
}
|
|
1070
|
-
function rgb(r, g, b, opacity) {
|
|
1071
|
-
return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
|
|
1072
|
-
}
|
|
1073
|
-
function Rgb(r, g, b, opacity) {
|
|
1074
|
-
this.r = +r;
|
|
1075
|
-
this.g = +g;
|
|
1076
|
-
this.b = +b;
|
|
1077
|
-
this.opacity = +opacity;
|
|
1078
|
-
}
|
|
1079
|
-
define(Rgb, rgb, extend(Color, {
|
|
1080
|
-
brighter(k) {
|
|
1081
|
-
k = k == null ? brighter : Math.pow(brighter, k);
|
|
1082
|
-
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
|
|
1083
|
-
},
|
|
1084
|
-
darker(k) {
|
|
1085
|
-
k = k == null ? darker : Math.pow(darker, k);
|
|
1086
|
-
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
|
|
1087
|
-
},
|
|
1088
|
-
rgb() {
|
|
1089
|
-
return this;
|
|
1090
|
-
},
|
|
1091
|
-
clamp() {
|
|
1092
|
-
return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
|
|
1093
|
-
},
|
|
1094
|
-
displayable() {
|
|
1095
|
-
return -0.5 <= this.r && this.r < 255.5 && (-0.5 <= this.g && this.g < 255.5) && (-0.5 <= this.b && this.b < 255.5) && (0 <= this.opacity && this.opacity <= 1);
|
|
1096
|
-
},
|
|
1097
|
-
hex: rgb_formatHex,
|
|
1098
|
-
// Deprecated! Use color.formatHex.
|
|
1099
|
-
formatHex: rgb_formatHex,
|
|
1100
|
-
formatHex8: rgb_formatHex8,
|
|
1101
|
-
formatRgb: rgb_formatRgb,
|
|
1102
|
-
toString: rgb_formatRgb
|
|
1103
|
-
}));
|
|
1104
|
-
function rgb_formatHex() {
|
|
1105
|
-
return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`;
|
|
1106
|
-
}
|
|
1107
|
-
function rgb_formatHex8() {
|
|
1108
|
-
return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
|
|
1109
|
-
}
|
|
1110
|
-
function rgb_formatRgb() {
|
|
1111
|
-
const a = clampa(this.opacity);
|
|
1112
|
-
return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`;
|
|
1113
|
-
}
|
|
1114
|
-
function clampa(opacity) {
|
|
1115
|
-
return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
|
|
1116
|
-
}
|
|
1117
|
-
function clampi(value) {
|
|
1118
|
-
return Math.max(0, Math.min(255, Math.round(value) || 0));
|
|
1119
|
-
}
|
|
1120
|
-
function hex(value) {
|
|
1121
|
-
value = clampi(value);
|
|
1122
|
-
return (value < 16 ? "0" : "") + value.toString(16);
|
|
1123
|
-
}
|
|
1124
|
-
function hsla(h, s, l, a) {
|
|
1125
|
-
if (a <= 0) h = s = l = NaN;
|
|
1126
|
-
else if (l <= 0 || l >= 1) h = s = NaN;
|
|
1127
|
-
else if (s <= 0) h = NaN;
|
|
1128
|
-
return new Hsl(h, s, l, a);
|
|
1129
|
-
}
|
|
1130
|
-
function hslConvert(o) {
|
|
1131
|
-
if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
|
|
1132
|
-
if (!(o instanceof Color)) o = color(o);
|
|
1133
|
-
if (!o) return new Hsl();
|
|
1134
|
-
if (o instanceof Hsl) return o;
|
|
1135
|
-
o = o.rgb();
|
|
1136
|
-
var r = o.r / 255, g = o.g / 255, b = o.b / 255, min = Math.min(r, g, b), max = Math.max(r, g, b), h = NaN, s = max - min, l = (max + min) / 2;
|
|
1137
|
-
if (s) {
|
|
1138
|
-
if (r === max) h = (g - b) / s + (g < b) * 6;
|
|
1139
|
-
else if (g === max) h = (b - r) / s + 2;
|
|
1140
|
-
else h = (r - g) / s + 4;
|
|
1141
|
-
s /= l < 0.5 ? max + min : 2 - max - min;
|
|
1142
|
-
h *= 60;
|
|
1143
|
-
} else {
|
|
1144
|
-
s = l > 0 && l < 1 ? 0 : h;
|
|
1145
|
-
}
|
|
1146
|
-
return new Hsl(h, s, l, o.opacity);
|
|
1147
|
-
}
|
|
1148
|
-
function hsl(h, s, l, opacity) {
|
|
1149
|
-
return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
|
|
1150
|
-
}
|
|
1151
|
-
function Hsl(h, s, l, opacity) {
|
|
1152
|
-
this.h = +h;
|
|
1153
|
-
this.s = +s;
|
|
1154
|
-
this.l = +l;
|
|
1155
|
-
this.opacity = +opacity;
|
|
1156
|
-
}
|
|
1157
|
-
define(Hsl, hsl, extend(Color, {
|
|
1158
|
-
brighter(k) {
|
|
1159
|
-
k = k == null ? brighter : Math.pow(brighter, k);
|
|
1160
|
-
return new Hsl(this.h, this.s, this.l * k, this.opacity);
|
|
1161
|
-
},
|
|
1162
|
-
darker(k) {
|
|
1163
|
-
k = k == null ? darker : Math.pow(darker, k);
|
|
1164
|
-
return new Hsl(this.h, this.s, this.l * k, this.opacity);
|
|
1165
|
-
},
|
|
1166
|
-
rgb() {
|
|
1167
|
-
var h = this.h % 360 + (this.h < 0) * 360, s = isNaN(h) || isNaN(this.s) ? 0 : this.s, l = this.l, m2 = l + (l < 0.5 ? l : 1 - l) * s, m1 = 2 * l - m2;
|
|
1168
|
-
return new Rgb(
|
|
1169
|
-
hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
|
|
1170
|
-
hsl2rgb(h, m1, m2),
|
|
1171
|
-
hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
|
|
1172
|
-
this.opacity
|
|
1173
|
-
);
|
|
1174
|
-
},
|
|
1175
|
-
clamp() {
|
|
1176
|
-
return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
|
|
1177
|
-
},
|
|
1178
|
-
displayable() {
|
|
1179
|
-
return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && (0 <= this.l && this.l <= 1) && (0 <= this.opacity && this.opacity <= 1);
|
|
1180
|
-
},
|
|
1181
|
-
formatHsl() {
|
|
1182
|
-
const a = clampa(this.opacity);
|
|
1183
|
-
return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`;
|
|
1184
|
-
}
|
|
1185
|
-
}));
|
|
1186
|
-
function clamph(value) {
|
|
1187
|
-
value = (value || 0) % 360;
|
|
1188
|
-
return value < 0 ? value + 360 : value;
|
|
1189
|
-
}
|
|
1190
|
-
function clampt(value) {
|
|
1191
|
-
return Math.max(0, Math.min(1, value || 0));
|
|
1192
|
-
}
|
|
1193
|
-
function hsl2rgb(h, m1, m2) {
|
|
1194
|
-
return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255;
|
|
1195
|
-
}
|
|
1196
|
-
const radians = Math.PI / 180;
|
|
1197
|
-
const degrees$1 = 180 / Math.PI;
|
|
1198
|
-
const K = 18, Xn = 0.96422, Yn = 1, Zn = 0.82521, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1;
|
|
1199
|
-
function labConvert(o) {
|
|
1200
|
-
if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
|
|
1201
|
-
if (o instanceof Hcl) return hcl2lab(o);
|
|
1202
|
-
if (!(o instanceof Rgb)) o = rgbConvert(o);
|
|
1203
|
-
var r = rgb2lrgb(o.r), g = rgb2lrgb(o.g), b = rgb2lrgb(o.b), y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z;
|
|
1204
|
-
if (r === g && g === b) x = z = y;
|
|
1205
|
-
else {
|
|
1206
|
-
x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);
|
|
1207
|
-
z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);
|
|
1208
|
-
}
|
|
1209
|
-
return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
|
|
1210
|
-
}
|
|
1211
|
-
function lab$1(l, a, b, opacity) {
|
|
1212
|
-
return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
|
|
1213
|
-
}
|
|
1214
|
-
function Lab(l, a, b, opacity) {
|
|
1215
|
-
this.l = +l;
|
|
1216
|
-
this.a = +a;
|
|
1217
|
-
this.b = +b;
|
|
1218
|
-
this.opacity = +opacity;
|
|
1219
|
-
}
|
|
1220
|
-
define(Lab, lab$1, extend(Color, {
|
|
1221
|
-
brighter(k) {
|
|
1222
|
-
return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity);
|
|
1223
|
-
},
|
|
1224
|
-
darker(k) {
|
|
1225
|
-
return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity);
|
|
1226
|
-
},
|
|
1227
|
-
rgb() {
|
|
1228
|
-
var y = (this.l + 16) / 116, x = isNaN(this.a) ? y : y + this.a / 500, z = isNaN(this.b) ? y : y - this.b / 200;
|
|
1229
|
-
x = Xn * lab2xyz(x);
|
|
1230
|
-
y = Yn * lab2xyz(y);
|
|
1231
|
-
z = Zn * lab2xyz(z);
|
|
1232
|
-
return new Rgb(
|
|
1233
|
-
lrgb2rgb(3.1338561 * x - 1.6168667 * y - 0.4906146 * z),
|
|
1234
|
-
lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.033454 * z),
|
|
1235
|
-
lrgb2rgb(0.0719453 * x - 0.2289914 * y + 1.4052427 * z),
|
|
1236
|
-
this.opacity
|
|
1237
|
-
);
|
|
1238
|
-
}
|
|
1239
|
-
}));
|
|
1240
|
-
function xyz2lab(t) {
|
|
1241
|
-
return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
|
|
1242
|
-
}
|
|
1243
|
-
function lab2xyz(t) {
|
|
1244
|
-
return t > t1 ? t * t * t : t2 * (t - t0);
|
|
1245
|
-
}
|
|
1246
|
-
function lrgb2rgb(x) {
|
|
1247
|
-
return 255 * (x <= 31308e-7 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
|
|
1248
|
-
}
|
|
1249
|
-
function rgb2lrgb(x) {
|
|
1250
|
-
return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
|
|
1251
|
-
}
|
|
1252
|
-
function hclConvert(o) {
|
|
1253
|
-
if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
|
|
1254
|
-
if (!(o instanceof Lab)) o = labConvert(o);
|
|
1255
|
-
if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity);
|
|
1256
|
-
var h = Math.atan2(o.b, o.a) * degrees$1;
|
|
1257
|
-
return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
|
|
1258
|
-
}
|
|
1259
|
-
function hcl(h, c, l, opacity) {
|
|
1260
|
-
return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
|
|
1261
|
-
}
|
|
1262
|
-
function Hcl(h, c, l, opacity) {
|
|
1263
|
-
this.h = +h;
|
|
1264
|
-
this.c = +c;
|
|
1265
|
-
this.l = +l;
|
|
1266
|
-
this.opacity = +opacity;
|
|
1267
|
-
}
|
|
1268
|
-
function hcl2lab(o) {
|
|
1269
|
-
if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity);
|
|
1270
|
-
var h = o.h * radians;
|
|
1271
|
-
return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
|
|
1272
|
-
}
|
|
1273
|
-
define(Hcl, hcl, extend(Color, {
|
|
1274
|
-
brighter(k) {
|
|
1275
|
-
return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity);
|
|
1276
|
-
},
|
|
1277
|
-
darker(k) {
|
|
1278
|
-
return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity);
|
|
1279
|
-
},
|
|
1280
|
-
rgb() {
|
|
1281
|
-
return hcl2lab(this).rgb();
|
|
1282
|
-
}
|
|
1283
|
-
}));
|
|
1284
|
-
const constant = (x) => () => x;
|
|
1285
|
-
function linear$1(a, d) {
|
|
1286
|
-
return function(t) {
|
|
1287
|
-
return a + t * d;
|
|
1288
|
-
};
|
|
1289
|
-
}
|
|
1290
|
-
function exponential(a, b, y) {
|
|
1291
|
-
return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
|
|
1292
|
-
return Math.pow(a + t * b, y);
|
|
1293
|
-
};
|
|
1294
|
-
}
|
|
1295
|
-
function gamma(y) {
|
|
1296
|
-
return (y = +y) === 1 ? nogamma : function(a, b) {
|
|
1297
|
-
return b - a ? exponential(a, b, y) : constant(isNaN(a) ? b : a);
|
|
1298
|
-
};
|
|
1299
|
-
}
|
|
1300
|
-
function nogamma(a, b) {
|
|
1301
|
-
var d = b - a;
|
|
1302
|
-
return d ? linear$1(a, d) : constant(isNaN(a) ? b : a);
|
|
1303
|
-
}
|
|
1304
|
-
const interpolateRgb = (function rgbGamma(y) {
|
|
1305
|
-
var color2 = gamma(y);
|
|
1306
|
-
function rgb$1(start2, end) {
|
|
1307
|
-
var r = color2((start2 = rgb(start2)).r, (end = rgb(end)).r), g = color2(start2.g, end.g), b = color2(start2.b, end.b), opacity = nogamma(start2.opacity, end.opacity);
|
|
1308
|
-
return function(t) {
|
|
1309
|
-
start2.r = r(t);
|
|
1310
|
-
start2.g = g(t);
|
|
1311
|
-
start2.b = b(t);
|
|
1312
|
-
start2.opacity = opacity(t);
|
|
1313
|
-
return start2 + "";
|
|
1314
|
-
};
|
|
1315
|
-
}
|
|
1316
|
-
rgb$1.gamma = rgbGamma;
|
|
1317
|
-
return rgb$1;
|
|
1318
|
-
})(1);
|
|
1319
|
-
function numberArray(a, b) {
|
|
1320
|
-
if (!b) b = [];
|
|
1321
|
-
var n = a ? Math.min(b.length, a.length) : 0, c = b.slice(), i;
|
|
1322
|
-
return function(t) {
|
|
1323
|
-
for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t;
|
|
1324
|
-
return c;
|
|
1325
|
-
};
|
|
1326
|
-
}
|
|
1327
|
-
function isNumberArray(x) {
|
|
1328
|
-
return ArrayBuffer.isView(x) && !(x instanceof DataView);
|
|
1329
|
-
}
|
|
1330
|
-
function genericArray(a, b) {
|
|
1331
|
-
var nb = b ? b.length : 0, na = a ? Math.min(nb, a.length) : 0, x = new Array(na), c = new Array(nb), i;
|
|
1332
|
-
for (i = 0; i < na; ++i) x[i] = interpolate$1(a[i], b[i]);
|
|
1333
|
-
for (; i < nb; ++i) c[i] = b[i];
|
|
1334
|
-
return function(t) {
|
|
1335
|
-
for (i = 0; i < na; ++i) c[i] = x[i](t);
|
|
1336
|
-
return c;
|
|
1337
|
-
};
|
|
1338
|
-
}
|
|
1339
|
-
function date(a, b) {
|
|
1340
|
-
var d = /* @__PURE__ */ new Date();
|
|
1341
|
-
return a = +a, b = +b, function(t) {
|
|
1342
|
-
return d.setTime(a * (1 - t) + b * t), d;
|
|
1343
|
-
};
|
|
1344
|
-
}
|
|
1345
|
-
function interpolateNumber(a, b) {
|
|
1346
|
-
return a = +a, b = +b, function(t) {
|
|
1347
|
-
return a * (1 - t) + b * t;
|
|
1348
|
-
};
|
|
1349
|
-
}
|
|
1350
|
-
function object(a, b) {
|
|
1351
|
-
var i = {}, c = {}, k;
|
|
1352
|
-
if (a === null || typeof a !== "object") a = {};
|
|
1353
|
-
if (b === null || typeof b !== "object") b = {};
|
|
1354
|
-
for (k in b) {
|
|
1355
|
-
if (k in a) {
|
|
1356
|
-
i[k] = interpolate$1(a[k], b[k]);
|
|
1357
|
-
} else {
|
|
1358
|
-
c[k] = b[k];
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
return function(t) {
|
|
1362
|
-
for (k in i) c[k] = i[k](t);
|
|
1363
|
-
return c;
|
|
1364
|
-
};
|
|
1365
|
-
}
|
|
1366
|
-
var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, reB = new RegExp(reA.source, "g");
|
|
1367
|
-
function zero(b) {
|
|
1368
|
-
return function() {
|
|
1369
|
-
return b;
|
|
1370
|
-
};
|
|
1371
|
-
}
|
|
1372
|
-
function one(b) {
|
|
1373
|
-
return function(t) {
|
|
1374
|
-
return b(t) + "";
|
|
1375
|
-
};
|
|
1376
|
-
}
|
|
1377
|
-
function interpolateString(a, b) {
|
|
1378
|
-
var bi = reA.lastIndex = reB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = [];
|
|
1379
|
-
a = a + "", b = b + "";
|
|
1380
|
-
while ((am = reA.exec(a)) && (bm = reB.exec(b))) {
|
|
1381
|
-
if ((bs = bm.index) > bi) {
|
|
1382
|
-
bs = b.slice(bi, bs);
|
|
1383
|
-
if (s[i]) s[i] += bs;
|
|
1384
|
-
else s[++i] = bs;
|
|
1385
|
-
}
|
|
1386
|
-
if ((am = am[0]) === (bm = bm[0])) {
|
|
1387
|
-
if (s[i]) s[i] += bm;
|
|
1388
|
-
else s[++i] = bm;
|
|
1389
|
-
} else {
|
|
1390
|
-
s[++i] = null;
|
|
1391
|
-
q.push({ i, x: interpolateNumber(am, bm) });
|
|
1392
|
-
}
|
|
1393
|
-
bi = reB.lastIndex;
|
|
1394
|
-
}
|
|
1395
|
-
if (bi < b.length) {
|
|
1396
|
-
bs = b.slice(bi);
|
|
1397
|
-
if (s[i]) s[i] += bs;
|
|
1398
|
-
else s[++i] = bs;
|
|
1399
|
-
}
|
|
1400
|
-
return s.length < 2 ? q[0] ? one(q[0].x) : zero(b) : (b = q.length, function(t) {
|
|
1401
|
-
for (var i2 = 0, o; i2 < b; ++i2) s[(o = q[i2]).i] = o.x(t);
|
|
1402
|
-
return s.join("");
|
|
1403
|
-
});
|
|
1404
|
-
}
|
|
1405
|
-
function interpolate$1(a, b) {
|
|
1406
|
-
var t = typeof b, c;
|
|
1407
|
-
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);
|
|
1408
|
-
}
|
|
1409
|
-
function interpolateRound(a, b) {
|
|
1410
|
-
return a = +a, b = +b, function(t) {
|
|
1411
|
-
return Math.round(a * (1 - t) + b * t);
|
|
1412
|
-
};
|
|
1413
|
-
}
|
|
1414
|
-
var degrees = 180 / Math.PI;
|
|
1415
|
-
var identity$2 = {
|
|
1416
|
-
translateX: 0,
|
|
1417
|
-
translateY: 0,
|
|
1418
|
-
rotate: 0,
|
|
1419
|
-
skewX: 0,
|
|
1420
|
-
scaleX: 1,
|
|
1421
|
-
scaleY: 1
|
|
1422
|
-
};
|
|
1423
|
-
function decompose(a, b, c, d, e, f) {
|
|
1424
|
-
var scaleX, scaleY, skewX;
|
|
1425
|
-
if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX;
|
|
1426
|
-
if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX;
|
|
1427
|
-
if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY;
|
|
1428
|
-
if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX;
|
|
1429
|
-
return {
|
|
1430
|
-
translateX: e,
|
|
1431
|
-
translateY: f,
|
|
1432
|
-
rotate: Math.atan2(b, a) * degrees,
|
|
1433
|
-
skewX: Math.atan(skewX) * degrees,
|
|
1434
|
-
scaleX,
|
|
1435
|
-
scaleY
|
|
1436
|
-
};
|
|
1437
|
-
}
|
|
1438
|
-
var svgNode;
|
|
1439
|
-
function parseCss(value) {
|
|
1440
|
-
const m = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + "");
|
|
1441
|
-
return m.isIdentity ? identity$2 : decompose(m.a, m.b, m.c, m.d, m.e, m.f);
|
|
1442
|
-
}
|
|
1443
|
-
function parseSvg(value) {
|
|
1444
|
-
if (value == null) return identity$2;
|
|
1445
|
-
if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
1446
|
-
svgNode.setAttribute("transform", value);
|
|
1447
|
-
if (!(value = svgNode.transform.baseVal.consolidate())) return identity$2;
|
|
1448
|
-
value = value.matrix;
|
|
1449
|
-
return decompose(value.a, value.b, value.c, value.d, value.e, value.f);
|
|
1450
|
-
}
|
|
1451
|
-
function interpolateTransform(parse, pxComma, pxParen, degParen) {
|
|
1452
|
-
function pop(s) {
|
|
1453
|
-
return s.length ? s.pop() + " " : "";
|
|
1454
|
-
}
|
|
1455
|
-
function translate(xa, ya, xb, yb, s, q) {
|
|
1456
|
-
if (xa !== xb || ya !== yb) {
|
|
1457
|
-
var i = s.push("translate(", null, pxComma, null, pxParen);
|
|
1458
|
-
q.push({ i: i - 4, x: interpolateNumber(xa, xb) }, { i: i - 2, x: interpolateNumber(ya, yb) });
|
|
1459
|
-
} else if (xb || yb) {
|
|
1460
|
-
s.push("translate(" + xb + pxComma + yb + pxParen);
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
function rotate(a, b, s, q) {
|
|
1464
|
-
if (a !== b) {
|
|
1465
|
-
if (a - b > 180) b += 360;
|
|
1466
|
-
else if (b - a > 180) a += 360;
|
|
1467
|
-
q.push({ i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: interpolateNumber(a, b) });
|
|
1468
|
-
} else if (b) {
|
|
1469
|
-
s.push(pop(s) + "rotate(" + b + degParen);
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
function skewX(a, b, s, q) {
|
|
1473
|
-
if (a !== b) {
|
|
1474
|
-
q.push({ i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: interpolateNumber(a, b) });
|
|
1475
|
-
} else if (b) {
|
|
1476
|
-
s.push(pop(s) + "skewX(" + b + degParen);
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
function scale(xa, ya, xb, yb, s, q) {
|
|
1480
|
-
if (xa !== xb || ya !== yb) {
|
|
1481
|
-
var i = s.push(pop(s) + "scale(", null, ",", null, ")");
|
|
1482
|
-
q.push({ i: i - 4, x: interpolateNumber(xa, xb) }, { i: i - 2, x: interpolateNumber(ya, yb) });
|
|
1483
|
-
} else if (xb !== 1 || yb !== 1) {
|
|
1484
|
-
s.push(pop(s) + "scale(" + xb + "," + yb + ")");
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
return function(a, b) {
|
|
1488
|
-
var s = [], q = [];
|
|
1489
|
-
a = parse(a), b = parse(b);
|
|
1490
|
-
translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q);
|
|
1491
|
-
rotate(a.rotate, b.rotate, s, q);
|
|
1492
|
-
skewX(a.skewX, b.skewX, s, q);
|
|
1493
|
-
scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q);
|
|
1494
|
-
a = b = null;
|
|
1495
|
-
return function(t) {
|
|
1496
|
-
var i = -1, n = q.length, o;
|
|
1497
|
-
while (++i < n) s[(o = q[i]).i] = o.x(t);
|
|
1498
|
-
return s.join("");
|
|
1499
|
-
};
|
|
1500
|
-
};
|
|
1501
|
-
}
|
|
1502
|
-
var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)");
|
|
1503
|
-
var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")");
|
|
1504
|
-
function lab(start2, end) {
|
|
1505
|
-
var l = nogamma((start2 = lab$1(start2)).l, (end = lab$1(end)).l), a = nogamma(start2.a, end.a), b = nogamma(start2.b, end.b), opacity = nogamma(start2.opacity, end.opacity);
|
|
1506
|
-
return function(t) {
|
|
1507
|
-
start2.l = l(t);
|
|
1508
|
-
start2.a = a(t);
|
|
1509
|
-
start2.b = b(t);
|
|
1510
|
-
start2.opacity = opacity(t);
|
|
1511
|
-
return start2 + "";
|
|
1512
|
-
};
|
|
1513
|
-
}
|
|
1514
|
-
var frame = 0, timeout$1 = 0, interval = 0, pokeDelay = 1e3, taskHead, taskTail, clockLast = 0, clockNow = 0, clockSkew = 0, clock = typeof performance === "object" && performance.now ? performance : Date, setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) {
|
|
1515
|
-
setTimeout(f, 17);
|
|
1516
|
-
};
|
|
1517
|
-
function now() {
|
|
1518
|
-
return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
|
|
1519
|
-
}
|
|
1520
|
-
function clearNow() {
|
|
1521
|
-
clockNow = 0;
|
|
1522
|
-
}
|
|
1523
|
-
function Timer() {
|
|
1524
|
-
this._call = this._time = this._next = null;
|
|
1525
|
-
}
|
|
1526
|
-
Timer.prototype = timer.prototype = {
|
|
1527
|
-
constructor: Timer,
|
|
1528
|
-
restart: function(callback, delay, time) {
|
|
1529
|
-
if (typeof callback !== "function") throw new TypeError("callback is not a function");
|
|
1530
|
-
time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
|
|
1531
|
-
if (!this._next && taskTail !== this) {
|
|
1532
|
-
if (taskTail) taskTail._next = this;
|
|
1533
|
-
else taskHead = this;
|
|
1534
|
-
taskTail = this;
|
|
1535
|
-
}
|
|
1536
|
-
this._call = callback;
|
|
1537
|
-
this._time = time;
|
|
1538
|
-
sleep();
|
|
1539
|
-
},
|
|
1540
|
-
stop: function() {
|
|
1541
|
-
if (this._call) {
|
|
1542
|
-
this._call = null;
|
|
1543
|
-
this._time = Infinity;
|
|
1544
|
-
sleep();
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
};
|
|
1548
|
-
function timer(callback, delay, time) {
|
|
1549
|
-
var t = new Timer();
|
|
1550
|
-
t.restart(callback, delay, time);
|
|
1551
|
-
return t;
|
|
1552
|
-
}
|
|
1553
|
-
function timerFlush() {
|
|
1554
|
-
now();
|
|
1555
|
-
++frame;
|
|
1556
|
-
var t = taskHead, e;
|
|
1557
|
-
while (t) {
|
|
1558
|
-
if ((e = clockNow - t._time) >= 0) t._call.call(void 0, e);
|
|
1559
|
-
t = t._next;
|
|
1560
|
-
}
|
|
1561
|
-
--frame;
|
|
1562
|
-
}
|
|
1563
|
-
function wake() {
|
|
1564
|
-
clockNow = (clockLast = clock.now()) + clockSkew;
|
|
1565
|
-
frame = timeout$1 = 0;
|
|
1566
|
-
try {
|
|
1567
|
-
timerFlush();
|
|
1568
|
-
} finally {
|
|
1569
|
-
frame = 0;
|
|
1570
|
-
nap();
|
|
1571
|
-
clockNow = 0;
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
function poke() {
|
|
1575
|
-
var now2 = clock.now(), delay = now2 - clockLast;
|
|
1576
|
-
if (delay > pokeDelay) clockSkew -= delay, clockLast = now2;
|
|
1577
|
-
}
|
|
1578
|
-
function nap() {
|
|
1579
|
-
var t02, t12 = taskHead, t22, time = Infinity;
|
|
1580
|
-
while (t12) {
|
|
1581
|
-
if (t12._call) {
|
|
1582
|
-
if (time > t12._time) time = t12._time;
|
|
1583
|
-
t02 = t12, t12 = t12._next;
|
|
1584
|
-
} else {
|
|
1585
|
-
t22 = t12._next, t12._next = null;
|
|
1586
|
-
t12 = t02 ? t02._next = t22 : taskHead = t22;
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
taskTail = t02;
|
|
1590
|
-
sleep(time);
|
|
1591
|
-
}
|
|
1592
|
-
function sleep(time) {
|
|
1593
|
-
if (frame) return;
|
|
1594
|
-
if (timeout$1) timeout$1 = clearTimeout(timeout$1);
|
|
1595
|
-
var delay = time - clockNow;
|
|
1596
|
-
if (delay > 24) {
|
|
1597
|
-
if (time < Infinity) timeout$1 = setTimeout(wake, time - clock.now() - clockSkew);
|
|
1598
|
-
if (interval) interval = clearInterval(interval);
|
|
1599
|
-
} else {
|
|
1600
|
-
if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
|
|
1601
|
-
frame = 1, setFrame(wake);
|
|
1602
|
-
}
|
|
1603
|
-
}
|
|
1604
|
-
function timeout(callback, delay, time) {
|
|
1605
|
-
var t = new Timer();
|
|
1606
|
-
delay = delay == null ? 0 : +delay;
|
|
1607
|
-
t.restart((elapsed) => {
|
|
1608
|
-
t.stop();
|
|
1609
|
-
callback(elapsed + delay);
|
|
1610
|
-
}, delay, time);
|
|
1611
|
-
return t;
|
|
1612
|
-
}
|
|
1613
|
-
var emptyOn = dispatch("start", "end", "cancel", "interrupt");
|
|
1614
|
-
var emptyTween = [];
|
|
1615
|
-
var CREATED = 0;
|
|
1616
|
-
var SCHEDULED = 1;
|
|
1617
|
-
var STARTING = 2;
|
|
1618
|
-
var STARTED = 3;
|
|
1619
|
-
var RUNNING = 4;
|
|
1620
|
-
var ENDING = 5;
|
|
1621
|
-
var ENDED = 6;
|
|
1622
|
-
function schedule(node, name, id2, index, group, timing) {
|
|
1623
|
-
var schedules = node.__transition;
|
|
1624
|
-
if (!schedules) node.__transition = {};
|
|
1625
|
-
else if (id2 in schedules) return;
|
|
1626
|
-
create(node, id2, {
|
|
1627
|
-
name,
|
|
1628
|
-
index,
|
|
1629
|
-
// For context during callback.
|
|
1630
|
-
group,
|
|
1631
|
-
// For context during callback.
|
|
1632
|
-
on: emptyOn,
|
|
1633
|
-
tween: emptyTween,
|
|
1634
|
-
time: timing.time,
|
|
1635
|
-
delay: timing.delay,
|
|
1636
|
-
duration: timing.duration,
|
|
1637
|
-
ease: timing.ease,
|
|
1638
|
-
timer: null,
|
|
1639
|
-
state: CREATED
|
|
1640
|
-
});
|
|
1641
|
-
}
|
|
1642
|
-
function init(node, id2) {
|
|
1643
|
-
var schedule2 = get(node, id2);
|
|
1644
|
-
if (schedule2.state > CREATED) throw new Error("too late; already scheduled");
|
|
1645
|
-
return schedule2;
|
|
1646
|
-
}
|
|
1647
|
-
function set(node, id2) {
|
|
1648
|
-
var schedule2 = get(node, id2);
|
|
1649
|
-
if (schedule2.state > STARTED) throw new Error("too late; already running");
|
|
1650
|
-
return schedule2;
|
|
1651
|
-
}
|
|
1652
|
-
function get(node, id2) {
|
|
1653
|
-
var schedule2 = node.__transition;
|
|
1654
|
-
if (!schedule2 || !(schedule2 = schedule2[id2])) throw new Error("transition not found");
|
|
1655
|
-
return schedule2;
|
|
1656
|
-
}
|
|
1657
|
-
function create(node, id2, self) {
|
|
1658
|
-
var schedules = node.__transition, tween;
|
|
1659
|
-
schedules[id2] = self;
|
|
1660
|
-
self.timer = timer(schedule2, 0, self.time);
|
|
1661
|
-
function schedule2(elapsed) {
|
|
1662
|
-
self.state = SCHEDULED;
|
|
1663
|
-
self.timer.restart(start2, self.delay, self.time);
|
|
1664
|
-
if (self.delay <= elapsed) start2(elapsed - self.delay);
|
|
1665
|
-
}
|
|
1666
|
-
function start2(elapsed) {
|
|
1667
|
-
var i, j, n, o;
|
|
1668
|
-
if (self.state !== SCHEDULED) return stop();
|
|
1669
|
-
for (i in schedules) {
|
|
1670
|
-
o = schedules[i];
|
|
1671
|
-
if (o.name !== self.name) continue;
|
|
1672
|
-
if (o.state === STARTED) return timeout(start2);
|
|
1673
|
-
if (o.state === RUNNING) {
|
|
1674
|
-
o.state = ENDED;
|
|
1675
|
-
o.timer.stop();
|
|
1676
|
-
o.on.call("interrupt", node, node.__data__, o.index, o.group);
|
|
1677
|
-
delete schedules[i];
|
|
1678
|
-
} else if (+i < id2) {
|
|
1679
|
-
o.state = ENDED;
|
|
1680
|
-
o.timer.stop();
|
|
1681
|
-
o.on.call("cancel", node, node.__data__, o.index, o.group);
|
|
1682
|
-
delete schedules[i];
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
timeout(function() {
|
|
1686
|
-
if (self.state === STARTED) {
|
|
1687
|
-
self.state = RUNNING;
|
|
1688
|
-
self.timer.restart(tick, self.delay, self.time);
|
|
1689
|
-
tick(elapsed);
|
|
1690
|
-
}
|
|
1691
|
-
});
|
|
1692
|
-
self.state = STARTING;
|
|
1693
|
-
self.on.call("start", node, node.__data__, self.index, self.group);
|
|
1694
|
-
if (self.state !== STARTING) return;
|
|
1695
|
-
self.state = STARTED;
|
|
1696
|
-
tween = new Array(n = self.tween.length);
|
|
1697
|
-
for (i = 0, j = -1; i < n; ++i) {
|
|
1698
|
-
if (o = self.tween[i].value.call(node, node.__data__, self.index, self.group)) {
|
|
1699
|
-
tween[++j] = o;
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
tween.length = j + 1;
|
|
1703
|
-
}
|
|
1704
|
-
function tick(elapsed) {
|
|
1705
|
-
var t = elapsed < self.duration ? self.ease.call(null, elapsed / self.duration) : (self.timer.restart(stop), self.state = ENDING, 1), i = -1, n = tween.length;
|
|
1706
|
-
while (++i < n) {
|
|
1707
|
-
tween[i].call(node, t);
|
|
1708
|
-
}
|
|
1709
|
-
if (self.state === ENDING) {
|
|
1710
|
-
self.on.call("end", node, node.__data__, self.index, self.group);
|
|
1711
|
-
stop();
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
function stop() {
|
|
1715
|
-
self.state = ENDED;
|
|
1716
|
-
self.timer.stop();
|
|
1717
|
-
delete schedules[id2];
|
|
1718
|
-
for (var i in schedules) return;
|
|
1719
|
-
delete node.__transition;
|
|
1720
|
-
}
|
|
1721
|
-
}
|
|
1722
|
-
function interrupt(node, name) {
|
|
1723
|
-
var schedules = node.__transition, schedule2, active, empty2 = true, i;
|
|
1724
|
-
if (!schedules) return;
|
|
1725
|
-
name = name == null ? null : name + "";
|
|
1726
|
-
for (i in schedules) {
|
|
1727
|
-
if ((schedule2 = schedules[i]).name !== name) {
|
|
1728
|
-
empty2 = false;
|
|
1729
|
-
continue;
|
|
1730
|
-
}
|
|
1731
|
-
active = schedule2.state > STARTING && schedule2.state < ENDING;
|
|
1732
|
-
schedule2.state = ENDED;
|
|
1733
|
-
schedule2.timer.stop();
|
|
1734
|
-
schedule2.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule2.index, schedule2.group);
|
|
1735
|
-
delete schedules[i];
|
|
1736
|
-
}
|
|
1737
|
-
if (empty2) delete node.__transition;
|
|
1738
|
-
}
|
|
1739
|
-
function selection_interrupt(name) {
|
|
1740
|
-
return this.each(function() {
|
|
1741
|
-
interrupt(this, name);
|
|
1742
|
-
});
|
|
1743
|
-
}
|
|
1744
|
-
function tweenRemove(id2, name) {
|
|
1745
|
-
var tween0, tween1;
|
|
1746
|
-
return function() {
|
|
1747
|
-
var schedule2 = set(this, id2), tween = schedule2.tween;
|
|
1748
|
-
if (tween !== tween0) {
|
|
1749
|
-
tween1 = tween0 = tween;
|
|
1750
|
-
for (var i = 0, n = tween1.length; i < n; ++i) {
|
|
1751
|
-
if (tween1[i].name === name) {
|
|
1752
|
-
tween1 = tween1.slice();
|
|
1753
|
-
tween1.splice(i, 1);
|
|
1754
|
-
break;
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
}
|
|
1758
|
-
schedule2.tween = tween1;
|
|
1759
|
-
};
|
|
1760
|
-
}
|
|
1761
|
-
function tweenFunction(id2, name, value) {
|
|
1762
|
-
var tween0, tween1;
|
|
1763
|
-
if (typeof value !== "function") throw new Error();
|
|
1764
|
-
return function() {
|
|
1765
|
-
var schedule2 = set(this, id2), tween = schedule2.tween;
|
|
1766
|
-
if (tween !== tween0) {
|
|
1767
|
-
tween1 = (tween0 = tween).slice();
|
|
1768
|
-
for (var t = { name, value }, i = 0, n = tween1.length; i < n; ++i) {
|
|
1769
|
-
if (tween1[i].name === name) {
|
|
1770
|
-
tween1[i] = t;
|
|
1771
|
-
break;
|
|
1772
|
-
}
|
|
1773
|
-
}
|
|
1774
|
-
if (i === n) tween1.push(t);
|
|
1775
|
-
}
|
|
1776
|
-
schedule2.tween = tween1;
|
|
1777
|
-
};
|
|
1778
|
-
}
|
|
1779
|
-
function transition_tween(name, value) {
|
|
1780
|
-
var id2 = this._id;
|
|
1781
|
-
name += "";
|
|
1782
|
-
if (arguments.length < 2) {
|
|
1783
|
-
var tween = get(this.node(), id2).tween;
|
|
1784
|
-
for (var i = 0, n = tween.length, t; i < n; ++i) {
|
|
1785
|
-
if ((t = tween[i]).name === name) {
|
|
1786
|
-
return t.value;
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
return null;
|
|
1790
|
-
}
|
|
1791
|
-
return this.each((value == null ? tweenRemove : tweenFunction)(id2, name, value));
|
|
1792
|
-
}
|
|
1793
|
-
function tweenValue(transition, name, value) {
|
|
1794
|
-
var id2 = transition._id;
|
|
1795
|
-
transition.each(function() {
|
|
1796
|
-
var schedule2 = set(this, id2);
|
|
1797
|
-
(schedule2.value || (schedule2.value = {}))[name] = value.apply(this, arguments);
|
|
1798
|
-
});
|
|
1799
|
-
return function(node) {
|
|
1800
|
-
return get(node, id2).value[name];
|
|
1801
|
-
};
|
|
1802
|
-
}
|
|
1803
|
-
function interpolate(a, b) {
|
|
1804
|
-
var c;
|
|
1805
|
-
return (typeof b === "number" ? interpolateNumber : b instanceof color ? interpolateRgb : (c = color(b)) ? (b = c, interpolateRgb) : interpolateString)(a, b);
|
|
1806
|
-
}
|
|
1807
|
-
function attrRemove(name) {
|
|
1808
|
-
return function() {
|
|
1809
|
-
this.removeAttribute(name);
|
|
1810
|
-
};
|
|
1811
|
-
}
|
|
1812
|
-
function attrRemoveNS(fullname) {
|
|
1813
|
-
return function() {
|
|
1814
|
-
this.removeAttributeNS(fullname.space, fullname.local);
|
|
1815
|
-
};
|
|
1816
|
-
}
|
|
1817
|
-
function attrConstant(name, interpolate2, value1) {
|
|
1818
|
-
var string00, string1 = value1 + "", interpolate0;
|
|
1819
|
-
return function() {
|
|
1820
|
-
var string0 = this.getAttribute(name);
|
|
1821
|
-
return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate2(string00 = string0, value1);
|
|
1822
|
-
};
|
|
1823
|
-
}
|
|
1824
|
-
function attrConstantNS(fullname, interpolate2, value1) {
|
|
1825
|
-
var string00, string1 = value1 + "", interpolate0;
|
|
1826
|
-
return function() {
|
|
1827
|
-
var string0 = this.getAttributeNS(fullname.space, fullname.local);
|
|
1828
|
-
return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate2(string00 = string0, value1);
|
|
1829
|
-
};
|
|
1830
|
-
}
|
|
1831
|
-
function attrFunction(name, interpolate2, value) {
|
|
1832
|
-
var string00, string10, interpolate0;
|
|
1833
|
-
return function() {
|
|
1834
|
-
var string0, value1 = value(this), string1;
|
|
1835
|
-
if (value1 == null) return void this.removeAttribute(name);
|
|
1836
|
-
string0 = this.getAttribute(name);
|
|
1837
|
-
string1 = value1 + "";
|
|
1838
|
-
return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate2(string00 = string0, value1));
|
|
1839
|
-
};
|
|
1840
|
-
}
|
|
1841
|
-
function attrFunctionNS(fullname, interpolate2, value) {
|
|
1842
|
-
var string00, string10, interpolate0;
|
|
1843
|
-
return function() {
|
|
1844
|
-
var string0, value1 = value(this), string1;
|
|
1845
|
-
if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local);
|
|
1846
|
-
string0 = this.getAttributeNS(fullname.space, fullname.local);
|
|
1847
|
-
string1 = value1 + "";
|
|
1848
|
-
return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate2(string00 = string0, value1));
|
|
1849
|
-
};
|
|
1850
|
-
}
|
|
1851
|
-
function transition_attr(name, value) {
|
|
1852
|
-
var fullname = namespace(name), i = fullname === "transform" ? interpolateTransformSvg : interpolate;
|
|
1853
|
-
return this.attrTween(name, typeof value === "function" ? (fullname.local ? attrFunctionNS : attrFunction)(fullname, i, tweenValue(this, "attr." + name, value)) : value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname) : (fullname.local ? attrConstantNS : attrConstant)(fullname, i, value));
|
|
1854
|
-
}
|
|
1855
|
-
function attrInterpolate(name, i) {
|
|
1856
|
-
return function(t) {
|
|
1857
|
-
this.setAttribute(name, i.call(this, t));
|
|
1858
|
-
};
|
|
1859
|
-
}
|
|
1860
|
-
function attrInterpolateNS(fullname, i) {
|
|
1861
|
-
return function(t) {
|
|
1862
|
-
this.setAttributeNS(fullname.space, fullname.local, i.call(this, t));
|
|
1863
|
-
};
|
|
1864
|
-
}
|
|
1865
|
-
function attrTweenNS(fullname, value) {
|
|
1866
|
-
var t02, i0;
|
|
1867
|
-
function tween() {
|
|
1868
|
-
var i = value.apply(this, arguments);
|
|
1869
|
-
if (i !== i0) t02 = (i0 = i) && attrInterpolateNS(fullname, i);
|
|
1870
|
-
return t02;
|
|
1871
|
-
}
|
|
1872
|
-
tween._value = value;
|
|
1873
|
-
return tween;
|
|
1874
|
-
}
|
|
1875
|
-
function attrTween(name, value) {
|
|
1876
|
-
var t02, i0;
|
|
1877
|
-
function tween() {
|
|
1878
|
-
var i = value.apply(this, arguments);
|
|
1879
|
-
if (i !== i0) t02 = (i0 = i) && attrInterpolate(name, i);
|
|
1880
|
-
return t02;
|
|
1881
|
-
}
|
|
1882
|
-
tween._value = value;
|
|
1883
|
-
return tween;
|
|
1884
|
-
}
|
|
1885
|
-
function transition_attrTween(name, value) {
|
|
1886
|
-
var key = "attr." + name;
|
|
1887
|
-
if (arguments.length < 2) return (key = this.tween(key)) && key._value;
|
|
1888
|
-
if (value == null) return this.tween(key, null);
|
|
1889
|
-
if (typeof value !== "function") throw new Error();
|
|
1890
|
-
var fullname = namespace(name);
|
|
1891
|
-
return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value));
|
|
1892
|
-
}
|
|
1893
|
-
function delayFunction(id2, value) {
|
|
1894
|
-
return function() {
|
|
1895
|
-
init(this, id2).delay = +value.apply(this, arguments);
|
|
1896
|
-
};
|
|
1897
|
-
}
|
|
1898
|
-
function delayConstant(id2, value) {
|
|
1899
|
-
return value = +value, function() {
|
|
1900
|
-
init(this, id2).delay = value;
|
|
1901
|
-
};
|
|
1902
|
-
}
|
|
1903
|
-
function transition_delay(value) {
|
|
1904
|
-
var id2 = this._id;
|
|
1905
|
-
return arguments.length ? this.each((typeof value === "function" ? delayFunction : delayConstant)(id2, value)) : get(this.node(), id2).delay;
|
|
1906
|
-
}
|
|
1907
|
-
function durationFunction(id2, value) {
|
|
1908
|
-
return function() {
|
|
1909
|
-
set(this, id2).duration = +value.apply(this, arguments);
|
|
1910
|
-
};
|
|
1911
|
-
}
|
|
1912
|
-
function durationConstant(id2, value) {
|
|
1913
|
-
return value = +value, function() {
|
|
1914
|
-
set(this, id2).duration = value;
|
|
1915
|
-
};
|
|
1916
|
-
}
|
|
1917
|
-
function transition_duration(value) {
|
|
1918
|
-
var id2 = this._id;
|
|
1919
|
-
return arguments.length ? this.each((typeof value === "function" ? durationFunction : durationConstant)(id2, value)) : get(this.node(), id2).duration;
|
|
1920
|
-
}
|
|
1921
|
-
function easeConstant(id2, value) {
|
|
1922
|
-
if (typeof value !== "function") throw new Error();
|
|
1923
|
-
return function() {
|
|
1924
|
-
set(this, id2).ease = value;
|
|
1925
|
-
};
|
|
1926
|
-
}
|
|
1927
|
-
function transition_ease(value) {
|
|
1928
|
-
var id2 = this._id;
|
|
1929
|
-
return arguments.length ? this.each(easeConstant(id2, value)) : get(this.node(), id2).ease;
|
|
1930
|
-
}
|
|
1931
|
-
function easeVarying(id2, value) {
|
|
1932
|
-
return function() {
|
|
1933
|
-
var v = value.apply(this, arguments);
|
|
1934
|
-
if (typeof v !== "function") throw new Error();
|
|
1935
|
-
set(this, id2).ease = v;
|
|
1936
|
-
};
|
|
1937
|
-
}
|
|
1938
|
-
function transition_easeVarying(value) {
|
|
1939
|
-
if (typeof value !== "function") throw new Error();
|
|
1940
|
-
return this.each(easeVarying(this._id, value));
|
|
1941
|
-
}
|
|
1942
|
-
function transition_filter(match) {
|
|
1943
|
-
if (typeof match !== "function") match = matcher(match);
|
|
1944
|
-
for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
|
|
1945
|
-
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
|
|
1946
|
-
if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
|
|
1947
|
-
subgroup.push(node);
|
|
1948
|
-
}
|
|
1949
|
-
}
|
|
1950
|
-
}
|
|
1951
|
-
return new Transition(subgroups, this._parents, this._name, this._id);
|
|
1952
|
-
}
|
|
1953
|
-
function transition_merge(transition) {
|
|
1954
|
-
if (transition._id !== this._id) throw new Error();
|
|
1955
|
-
for (var groups0 = this._groups, groups1 = transition._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
|
|
1956
|
-
for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
|
|
1957
|
-
if (node = group0[i] || group1[i]) {
|
|
1958
|
-
merge[i] = node;
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
}
|
|
1962
|
-
for (; j < m0; ++j) {
|
|
1963
|
-
merges[j] = groups0[j];
|
|
1964
|
-
}
|
|
1965
|
-
return new Transition(merges, this._parents, this._name, this._id);
|
|
1966
|
-
}
|
|
1967
|
-
function start(name) {
|
|
1968
|
-
return (name + "").trim().split(/^|\s+/).every(function(t) {
|
|
1969
|
-
var i = t.indexOf(".");
|
|
1970
|
-
if (i >= 0) t = t.slice(0, i);
|
|
1971
|
-
return !t || t === "start";
|
|
1972
|
-
});
|
|
1973
|
-
}
|
|
1974
|
-
function onFunction(id2, name, listener) {
|
|
1975
|
-
var on0, on1, sit = start(name) ? init : set;
|
|
1976
|
-
return function() {
|
|
1977
|
-
var schedule2 = sit(this, id2), on = schedule2.on;
|
|
1978
|
-
if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener);
|
|
1979
|
-
schedule2.on = on1;
|
|
1980
|
-
};
|
|
1981
|
-
}
|
|
1982
|
-
function transition_on(name, listener) {
|
|
1983
|
-
var id2 = this._id;
|
|
1984
|
-
return arguments.length < 2 ? get(this.node(), id2).on.on(name) : this.each(onFunction(id2, name, listener));
|
|
1985
|
-
}
|
|
1986
|
-
function removeFunction(id2) {
|
|
1987
|
-
return function() {
|
|
1988
|
-
var parent = this.parentNode;
|
|
1989
|
-
for (var i in this.__transition) if (+i !== id2) return;
|
|
1990
|
-
if (parent) parent.removeChild(this);
|
|
1991
|
-
};
|
|
1992
|
-
}
|
|
1993
|
-
function transition_remove() {
|
|
1994
|
-
return this.on("end.remove", removeFunction(this._id));
|
|
1995
|
-
}
|
|
1996
|
-
function transition_select(select) {
|
|
1997
|
-
var name = this._name, id2 = this._id;
|
|
1998
|
-
if (typeof select !== "function") select = selector(select);
|
|
1999
|
-
for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
|
|
2000
|
-
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
|
|
2001
|
-
if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
|
|
2002
|
-
if ("__data__" in node) subnode.__data__ = node.__data__;
|
|
2003
|
-
subgroup[i] = subnode;
|
|
2004
|
-
schedule(subgroup[i], name, id2, i, subgroup, get(node, id2));
|
|
2005
|
-
}
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
return new Transition(subgroups, this._parents, name, id2);
|
|
2009
|
-
}
|
|
2010
|
-
function transition_selectAll(select) {
|
|
2011
|
-
var name = this._name, id2 = this._id;
|
|
2012
|
-
if (typeof select !== "function") select = selectorAll(select);
|
|
2013
|
-
for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
|
|
2014
|
-
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
|
|
2015
|
-
if (node = group[i]) {
|
|
2016
|
-
for (var children2 = select.call(node, node.__data__, i, group), child, inherit2 = get(node, id2), k = 0, l = children2.length; k < l; ++k) {
|
|
2017
|
-
if (child = children2[k]) {
|
|
2018
|
-
schedule(child, name, id2, k, children2, inherit2);
|
|
2019
|
-
}
|
|
2020
|
-
}
|
|
2021
|
-
subgroups.push(children2);
|
|
2022
|
-
parents.push(node);
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
|
-
}
|
|
2026
|
-
return new Transition(subgroups, parents, name, id2);
|
|
2027
|
-
}
|
|
2028
|
-
var Selection = selection.prototype.constructor;
|
|
2029
|
-
function transition_selection() {
|
|
2030
|
-
return new Selection(this._groups, this._parents);
|
|
2031
|
-
}
|
|
2032
|
-
function styleNull(name, interpolate2) {
|
|
2033
|
-
var string00, string10, interpolate0;
|
|
2034
|
-
return function() {
|
|
2035
|
-
var string0 = styleValue(this, name), string1 = (this.style.removeProperty(name), styleValue(this, name));
|
|
2036
|
-
return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : interpolate0 = interpolate2(string00 = string0, string10 = string1);
|
|
2037
|
-
};
|
|
2038
|
-
}
|
|
2039
|
-
function styleRemove(name) {
|
|
2040
|
-
return function() {
|
|
2041
|
-
this.style.removeProperty(name);
|
|
2042
|
-
};
|
|
2043
|
-
}
|
|
2044
|
-
function styleConstant(name, interpolate2, value1) {
|
|
2045
|
-
var string00, string1 = value1 + "", interpolate0;
|
|
2046
|
-
return function() {
|
|
2047
|
-
var string0 = styleValue(this, name);
|
|
2048
|
-
return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate2(string00 = string0, value1);
|
|
2049
|
-
};
|
|
2050
|
-
}
|
|
2051
|
-
function styleFunction(name, interpolate2, value) {
|
|
2052
|
-
var string00, string10, interpolate0;
|
|
2053
|
-
return function() {
|
|
2054
|
-
var string0 = styleValue(this, name), value1 = value(this), string1 = value1 + "";
|
|
2055
|
-
if (value1 == null) string1 = value1 = (this.style.removeProperty(name), styleValue(this, name));
|
|
2056
|
-
return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate2(string00 = string0, value1));
|
|
2057
|
-
};
|
|
2058
|
-
}
|
|
2059
|
-
function styleMaybeRemove(id2, name) {
|
|
2060
|
-
var on0, on1, listener0, key = "style." + name, event = "end." + key, remove2;
|
|
2061
|
-
return function() {
|
|
2062
|
-
var schedule2 = set(this, id2), on = schedule2.on, listener = schedule2.value[key] == null ? remove2 || (remove2 = styleRemove(name)) : void 0;
|
|
2063
|
-
if (on !== on0 || listener0 !== listener) (on1 = (on0 = on).copy()).on(event, listener0 = listener);
|
|
2064
|
-
schedule2.on = on1;
|
|
2065
|
-
};
|
|
2066
|
-
}
|
|
2067
|
-
function transition_style(name, value, priority) {
|
|
2068
|
-
var i = (name += "") === "transform" ? interpolateTransformCss : interpolate;
|
|
2069
|
-
return value == null ? this.styleTween(name, styleNull(name, i)).on("end.style." + name, styleRemove(name)) : typeof value === "function" ? this.styleTween(name, styleFunction(name, i, tweenValue(this, "style." + name, value))).each(styleMaybeRemove(this._id, name)) : this.styleTween(name, styleConstant(name, i, value), priority).on("end.style." + name, null);
|
|
2070
|
-
}
|
|
2071
|
-
function styleInterpolate(name, i, priority) {
|
|
2072
|
-
return function(t) {
|
|
2073
|
-
this.style.setProperty(name, i.call(this, t), priority);
|
|
2074
|
-
};
|
|
2075
|
-
}
|
|
2076
|
-
function styleTween(name, value, priority) {
|
|
2077
|
-
var t, i0;
|
|
2078
|
-
function tween() {
|
|
2079
|
-
var i = value.apply(this, arguments);
|
|
2080
|
-
if (i !== i0) t = (i0 = i) && styleInterpolate(name, i, priority);
|
|
2081
|
-
return t;
|
|
2082
|
-
}
|
|
2083
|
-
tween._value = value;
|
|
2084
|
-
return tween;
|
|
2085
|
-
}
|
|
2086
|
-
function transition_styleTween(name, value, priority) {
|
|
2087
|
-
var key = "style." + (name += "");
|
|
2088
|
-
if (arguments.length < 2) return (key = this.tween(key)) && key._value;
|
|
2089
|
-
if (value == null) return this.tween(key, null);
|
|
2090
|
-
if (typeof value !== "function") throw new Error();
|
|
2091
|
-
return this.tween(key, styleTween(name, value, priority == null ? "" : priority));
|
|
2092
|
-
}
|
|
2093
|
-
function textConstant(value) {
|
|
2094
|
-
return function() {
|
|
2095
|
-
this.textContent = value;
|
|
2096
|
-
};
|
|
2097
|
-
}
|
|
2098
|
-
function textFunction(value) {
|
|
2099
|
-
return function() {
|
|
2100
|
-
var value1 = value(this);
|
|
2101
|
-
this.textContent = value1 == null ? "" : value1;
|
|
2102
|
-
};
|
|
2103
|
-
}
|
|
2104
|
-
function transition_text(value) {
|
|
2105
|
-
return this.tween("text", typeof value === "function" ? textFunction(tweenValue(this, "text", value)) : textConstant(value == null ? "" : value + ""));
|
|
2106
|
-
}
|
|
2107
|
-
function textInterpolate(i) {
|
|
2108
|
-
return function(t) {
|
|
2109
|
-
this.textContent = i.call(this, t);
|
|
2110
|
-
};
|
|
2111
|
-
}
|
|
2112
|
-
function textTween(value) {
|
|
2113
|
-
var t02, i0;
|
|
2114
|
-
function tween() {
|
|
2115
|
-
var i = value.apply(this, arguments);
|
|
2116
|
-
if (i !== i0) t02 = (i0 = i) && textInterpolate(i);
|
|
2117
|
-
return t02;
|
|
2118
|
-
}
|
|
2119
|
-
tween._value = value;
|
|
2120
|
-
return tween;
|
|
2121
|
-
}
|
|
2122
|
-
function transition_textTween(value) {
|
|
2123
|
-
var key = "text";
|
|
2124
|
-
if (arguments.length < 1) return (key = this.tween(key)) && key._value;
|
|
2125
|
-
if (value == null) return this.tween(key, null);
|
|
2126
|
-
if (typeof value !== "function") throw new Error();
|
|
2127
|
-
return this.tween(key, textTween(value));
|
|
2128
|
-
}
|
|
2129
|
-
function transition_transition() {
|
|
2130
|
-
var name = this._name, id0 = this._id, id1 = newId();
|
|
2131
|
-
for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
|
|
2132
|
-
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
|
|
2133
|
-
if (node = group[i]) {
|
|
2134
|
-
var inherit2 = get(node, id0);
|
|
2135
|
-
schedule(node, name, id1, i, group, {
|
|
2136
|
-
time: inherit2.time + inherit2.delay + inherit2.duration,
|
|
2137
|
-
delay: 0,
|
|
2138
|
-
duration: inherit2.duration,
|
|
2139
|
-
ease: inherit2.ease
|
|
2140
|
-
});
|
|
2141
|
-
}
|
|
2142
|
-
}
|
|
2143
|
-
}
|
|
2144
|
-
return new Transition(groups, this._parents, name, id1);
|
|
2145
|
-
}
|
|
2146
|
-
function transition_end() {
|
|
2147
|
-
var on0, on1, that = this, id2 = that._id, size = that.size();
|
|
2148
|
-
return new Promise(function(resolve, reject) {
|
|
2149
|
-
var cancel = { value: reject }, end = { value: function() {
|
|
2150
|
-
if (--size === 0) resolve();
|
|
2151
|
-
} };
|
|
2152
|
-
that.each(function() {
|
|
2153
|
-
var schedule2 = set(this, id2), on = schedule2.on;
|
|
2154
|
-
if (on !== on0) {
|
|
2155
|
-
on1 = (on0 = on).copy();
|
|
2156
|
-
on1._.cancel.push(cancel);
|
|
2157
|
-
on1._.interrupt.push(cancel);
|
|
2158
|
-
on1._.end.push(end);
|
|
2159
|
-
}
|
|
2160
|
-
schedule2.on = on1;
|
|
2161
|
-
});
|
|
2162
|
-
if (size === 0) resolve();
|
|
2163
|
-
});
|
|
2164
|
-
}
|
|
2165
|
-
var id = 0;
|
|
2166
|
-
function Transition(groups, parents, name, id2) {
|
|
2167
|
-
this._groups = groups;
|
|
2168
|
-
this._parents = parents;
|
|
2169
|
-
this._name = name;
|
|
2170
|
-
this._id = id2;
|
|
2171
|
-
}
|
|
2172
|
-
function newId() {
|
|
2173
|
-
return ++id;
|
|
2174
|
-
}
|
|
2175
|
-
var selection_prototype = selection.prototype;
|
|
2176
|
-
Transition.prototype = {
|
|
2177
|
-
constructor: Transition,
|
|
2178
|
-
select: transition_select,
|
|
2179
|
-
selectAll: transition_selectAll,
|
|
2180
|
-
selectChild: selection_prototype.selectChild,
|
|
2181
|
-
selectChildren: selection_prototype.selectChildren,
|
|
2182
|
-
filter: transition_filter,
|
|
2183
|
-
merge: transition_merge,
|
|
2184
|
-
selection: transition_selection,
|
|
2185
|
-
transition: transition_transition,
|
|
2186
|
-
call: selection_prototype.call,
|
|
2187
|
-
nodes: selection_prototype.nodes,
|
|
2188
|
-
node: selection_prototype.node,
|
|
2189
|
-
size: selection_prototype.size,
|
|
2190
|
-
empty: selection_prototype.empty,
|
|
2191
|
-
each: selection_prototype.each,
|
|
2192
|
-
on: transition_on,
|
|
2193
|
-
attr: transition_attr,
|
|
2194
|
-
attrTween: transition_attrTween,
|
|
2195
|
-
style: transition_style,
|
|
2196
|
-
styleTween: transition_styleTween,
|
|
2197
|
-
text: transition_text,
|
|
2198
|
-
textTween: transition_textTween,
|
|
2199
|
-
remove: transition_remove,
|
|
2200
|
-
tween: transition_tween,
|
|
2201
|
-
delay: transition_delay,
|
|
2202
|
-
duration: transition_duration,
|
|
2203
|
-
ease: transition_ease,
|
|
2204
|
-
easeVarying: transition_easeVarying,
|
|
2205
|
-
end: transition_end,
|
|
2206
|
-
[Symbol.iterator]: selection_prototype[Symbol.iterator]
|
|
2207
|
-
};
|
|
2208
|
-
function cubicInOut(t) {
|
|
2209
|
-
return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
|
|
2210
|
-
}
|
|
2211
|
-
var defaultTiming = {
|
|
2212
|
-
time: null,
|
|
2213
|
-
// Set on use.
|
|
2214
|
-
delay: 0,
|
|
2215
|
-
duration: 250,
|
|
2216
|
-
ease: cubicInOut
|
|
2217
|
-
};
|
|
2218
|
-
function inherit(node, id2) {
|
|
2219
|
-
var timing;
|
|
2220
|
-
while (!(timing = node.__transition) || !(timing = timing[id2])) {
|
|
2221
|
-
if (!(node = node.parentNode)) {
|
|
2222
|
-
throw new Error(`transition ${id2} not found`);
|
|
2223
|
-
}
|
|
2224
|
-
}
|
|
2225
|
-
return timing;
|
|
2226
|
-
}
|
|
2227
|
-
function selection_transition(name) {
|
|
2228
|
-
var id2, timing;
|
|
2229
|
-
if (name instanceof Transition) {
|
|
2230
|
-
id2 = name._id, name = name._name;
|
|
2231
|
-
} else {
|
|
2232
|
-
id2 = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + "";
|
|
2233
|
-
}
|
|
2234
|
-
for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
|
|
2235
|
-
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
|
|
2236
|
-
if (node = group[i]) {
|
|
2237
|
-
schedule(node, name, id2, i, group, timing || inherit(node, id2));
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
}
|
|
2241
|
-
return new Transition(groups, this._parents, name, id2);
|
|
2242
|
-
}
|
|
2243
|
-
selection.prototype.interrupt = selection_interrupt;
|
|
2244
|
-
selection.prototype.transition = selection_transition;
|
|
2245
|
-
function formatDecimal(x) {
|
|
2246
|
-
return Math.abs(x = Math.round(x)) >= 1e21 ? x.toLocaleString("en").replace(/,/g, "") : x.toString(10);
|
|
2247
|
-
}
|
|
2248
|
-
function formatDecimalParts(x, p) {
|
|
2249
|
-
if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null;
|
|
2250
|
-
var i, coefficient = x.slice(0, i);
|
|
2251
|
-
return [
|
|
2252
|
-
coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
|
|
2253
|
-
+x.slice(i + 1)
|
|
2254
|
-
];
|
|
2255
|
-
}
|
|
2256
|
-
function exponent(x) {
|
|
2257
|
-
return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN;
|
|
2258
|
-
}
|
|
2259
|
-
function formatGroup(grouping, thousands) {
|
|
2260
|
-
return function(value, width) {
|
|
2261
|
-
var i = value.length, t = [], j = 0, g = grouping[0], length = 0;
|
|
2262
|
-
while (i > 0 && g > 0) {
|
|
2263
|
-
if (length + g + 1 > width) g = Math.max(1, width - length);
|
|
2264
|
-
t.push(value.substring(i -= g, i + g));
|
|
2265
|
-
if ((length += g + 1) > width) break;
|
|
2266
|
-
g = grouping[j = (j + 1) % grouping.length];
|
|
2267
|
-
}
|
|
2268
|
-
return t.reverse().join(thousands);
|
|
2269
|
-
};
|
|
2270
|
-
}
|
|
2271
|
-
function formatNumerals(numerals) {
|
|
2272
|
-
return function(value) {
|
|
2273
|
-
return value.replace(/[0-9]/g, function(i) {
|
|
2274
|
-
return numerals[+i];
|
|
2275
|
-
});
|
|
2276
|
-
};
|
|
2277
|
-
}
|
|
2278
|
-
var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
|
|
2279
|
-
function formatSpecifier(specifier) {
|
|
2280
|
-
if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
|
|
2281
|
-
var match;
|
|
2282
|
-
return new FormatSpecifier({
|
|
2283
|
-
fill: match[1],
|
|
2284
|
-
align: match[2],
|
|
2285
|
-
sign: match[3],
|
|
2286
|
-
symbol: match[4],
|
|
2287
|
-
zero: match[5],
|
|
2288
|
-
width: match[6],
|
|
2289
|
-
comma: match[7],
|
|
2290
|
-
precision: match[8] && match[8].slice(1),
|
|
2291
|
-
trim: match[9],
|
|
2292
|
-
type: match[10]
|
|
2293
|
-
});
|
|
2294
|
-
}
|
|
2295
|
-
formatSpecifier.prototype = FormatSpecifier.prototype;
|
|
2296
|
-
function FormatSpecifier(specifier) {
|
|
2297
|
-
this.fill = specifier.fill === void 0 ? " " : specifier.fill + "";
|
|
2298
|
-
this.align = specifier.align === void 0 ? ">" : specifier.align + "";
|
|
2299
|
-
this.sign = specifier.sign === void 0 ? "-" : specifier.sign + "";
|
|
2300
|
-
this.symbol = specifier.symbol === void 0 ? "" : specifier.symbol + "";
|
|
2301
|
-
this.zero = !!specifier.zero;
|
|
2302
|
-
this.width = specifier.width === void 0 ? void 0 : +specifier.width;
|
|
2303
|
-
this.comma = !!specifier.comma;
|
|
2304
|
-
this.precision = specifier.precision === void 0 ? void 0 : +specifier.precision;
|
|
2305
|
-
this.trim = !!specifier.trim;
|
|
2306
|
-
this.type = specifier.type === void 0 ? "" : specifier.type + "";
|
|
2307
|
-
}
|
|
2308
|
-
FormatSpecifier.prototype.toString = function() {
|
|
2309
|
-
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;
|
|
2310
|
-
};
|
|
2311
|
-
function formatTrim(s) {
|
|
2312
|
-
out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
|
|
2313
|
-
switch (s[i]) {
|
|
2314
|
-
case ".":
|
|
2315
|
-
i0 = i1 = i;
|
|
2316
|
-
break;
|
|
2317
|
-
case "0":
|
|
2318
|
-
if (i0 === 0) i0 = i;
|
|
2319
|
-
i1 = i;
|
|
2320
|
-
break;
|
|
2321
|
-
default:
|
|
2322
|
-
if (!+s[i]) break out;
|
|
2323
|
-
if (i0 > 0) i0 = 0;
|
|
2324
|
-
break;
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
2327
|
-
return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
|
|
2328
|
-
}
|
|
2329
|
-
var prefixExponent;
|
|
2330
|
-
function formatPrefixAuto(x, p) {
|
|
2331
|
-
var d = formatDecimalParts(x, p);
|
|
2332
|
-
if (!d) return x + "";
|
|
2333
|
-
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;
|
|
2334
|
-
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];
|
|
2335
|
-
}
|
|
2336
|
-
function formatRounded(x, p) {
|
|
2337
|
-
var d = formatDecimalParts(x, p);
|
|
2338
|
-
if (!d) return x + "";
|
|
2339
|
-
var coefficient = d[0], exponent2 = d[1];
|
|
2340
|
-
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");
|
|
2341
|
-
}
|
|
2342
|
-
const formatTypes = {
|
|
2343
|
-
"%": (x, p) => (x * 100).toFixed(p),
|
|
2344
|
-
"b": (x) => Math.round(x).toString(2),
|
|
2345
|
-
"c": (x) => x + "",
|
|
2346
|
-
"d": formatDecimal,
|
|
2347
|
-
"e": (x, p) => x.toExponential(p),
|
|
2348
|
-
"f": (x, p) => x.toFixed(p),
|
|
2349
|
-
"g": (x, p) => x.toPrecision(p),
|
|
2350
|
-
"o": (x) => Math.round(x).toString(8),
|
|
2351
|
-
"p": (x, p) => formatRounded(x * 100, p),
|
|
2352
|
-
"r": formatRounded,
|
|
2353
|
-
"s": formatPrefixAuto,
|
|
2354
|
-
"X": (x) => Math.round(x).toString(16).toUpperCase(),
|
|
2355
|
-
"x": (x) => Math.round(x).toString(16)
|
|
2356
|
-
};
|
|
2357
|
-
function identity$1(x) {
|
|
2358
|
-
return x;
|
|
2359
|
-
}
|
|
2360
|
-
var map = Array.prototype.map, prefixes = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
|
|
2361
|
-
function formatLocale(locale2) {
|
|
2362
|
-
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 + "";
|
|
2363
|
-
function newFormat(specifier) {
|
|
2364
|
-
specifier = formatSpecifier(specifier);
|
|
2365
|
-
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;
|
|
2366
|
-
if (type === "n") comma = true, type = "g";
|
|
2367
|
-
else if (!formatTypes[type]) precision === void 0 && (precision = 12), trim = true, type = "g";
|
|
2368
|
-
if (zero2 || fill === "0" && align === "=") zero2 = true, fill = "0", align = "=";
|
|
2369
|
-
var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "";
|
|
2370
|
-
var formatType = formatTypes[type], maybeSuffix = /[defgprs%]/.test(type);
|
|
2371
|
-
precision = precision === void 0 ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision));
|
|
2372
|
-
function format2(value) {
|
|
2373
|
-
var valuePrefix = prefix, valueSuffix = suffix, i, n, c;
|
|
2374
|
-
if (type === "c") {
|
|
2375
|
-
valueSuffix = formatType(value) + valueSuffix;
|
|
2376
|
-
value = "";
|
|
2377
|
-
} else {
|
|
2378
|
-
value = +value;
|
|
2379
|
-
var valueNegative = value < 0 || 1 / value < 0;
|
|
2380
|
-
value = isNaN(value) ? nan : formatType(Math.abs(value), precision);
|
|
2381
|
-
if (trim) value = formatTrim(value);
|
|
2382
|
-
if (valueNegative && +value === 0 && sign !== "+") valueNegative = false;
|
|
2383
|
-
valuePrefix = (valueNegative ? sign === "(" ? sign : minus : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
|
|
2384
|
-
valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : "");
|
|
2385
|
-
if (maybeSuffix) {
|
|
2386
|
-
i = -1, n = value.length;
|
|
2387
|
-
while (++i < n) {
|
|
2388
|
-
if (c = value.charCodeAt(i), 48 > c || c > 57) {
|
|
2389
|
-
valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix;
|
|
2390
|
-
value = value.slice(0, i);
|
|
2391
|
-
break;
|
|
2392
|
-
}
|
|
2393
|
-
}
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2396
|
-
if (comma && !zero2) value = group(value, Infinity);
|
|
2397
|
-
var length = valuePrefix.length + value.length + valueSuffix.length, padding = length < width ? new Array(width - length + 1).join(fill) : "";
|
|
2398
|
-
if (comma && zero2) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
|
|
2399
|
-
switch (align) {
|
|
2400
|
-
case "<":
|
|
2401
|
-
value = valuePrefix + value + valueSuffix + padding;
|
|
2402
|
-
break;
|
|
2403
|
-
case "=":
|
|
2404
|
-
value = valuePrefix + padding + value + valueSuffix;
|
|
2405
|
-
break;
|
|
2406
|
-
case "^":
|
|
2407
|
-
value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length);
|
|
2408
|
-
break;
|
|
2409
|
-
default:
|
|
2410
|
-
value = padding + valuePrefix + value + valueSuffix;
|
|
2411
|
-
break;
|
|
2412
|
-
}
|
|
2413
|
-
return numerals(value);
|
|
2414
|
-
}
|
|
2415
|
-
format2.toString = function() {
|
|
2416
|
-
return specifier + "";
|
|
2417
|
-
};
|
|
2418
|
-
return format2;
|
|
2419
|
-
}
|
|
2420
|
-
function formatPrefix2(specifier, value) {
|
|
2421
|
-
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];
|
|
2422
|
-
return function(value2) {
|
|
2423
|
-
return f(k * value2) + prefix;
|
|
2424
|
-
};
|
|
2425
|
-
}
|
|
2426
|
-
return {
|
|
2427
|
-
format: newFormat,
|
|
2428
|
-
formatPrefix: formatPrefix2
|
|
2429
|
-
};
|
|
2430
|
-
}
|
|
2431
|
-
var locale;
|
|
2432
|
-
var format;
|
|
2433
|
-
var formatPrefix;
|
|
2434
|
-
defaultLocale({
|
|
2435
|
-
thousands: ",",
|
|
2436
|
-
grouping: [3],
|
|
2437
|
-
currency: ["$", ""]
|
|
2438
|
-
});
|
|
2439
|
-
function defaultLocale(definition) {
|
|
2440
|
-
locale = formatLocale(definition);
|
|
2441
|
-
format = locale.format;
|
|
2442
|
-
formatPrefix = locale.formatPrefix;
|
|
2443
|
-
return locale;
|
|
2444
|
-
}
|
|
2445
|
-
function precisionFixed(step) {
|
|
2446
|
-
return Math.max(0, -exponent(Math.abs(step)));
|
|
2447
|
-
}
|
|
2448
|
-
function precisionPrefix(step, value) {
|
|
2449
|
-
return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step)));
|
|
2450
|
-
}
|
|
2451
|
-
function precisionRound(step, max) {
|
|
2452
|
-
step = Math.abs(step), max = Math.abs(max) - step;
|
|
2453
|
-
return Math.max(0, exponent(max) - exponent(step)) + 1;
|
|
2454
|
-
}
|
|
2455
|
-
function initRange(domain, range) {
|
|
2456
|
-
switch (arguments.length) {
|
|
2457
|
-
case 0:
|
|
2458
|
-
break;
|
|
2459
|
-
case 1:
|
|
2460
|
-
this.range(domain);
|
|
2461
|
-
break;
|
|
2462
|
-
default:
|
|
2463
|
-
this.range(range).domain(domain);
|
|
2464
|
-
break;
|
|
2465
|
-
}
|
|
2466
|
-
return this;
|
|
2467
|
-
}
|
|
2468
|
-
function constants(x) {
|
|
2469
|
-
return function() {
|
|
2470
|
-
return x;
|
|
2471
|
-
};
|
|
2472
|
-
}
|
|
2473
|
-
function number(x) {
|
|
2474
|
-
return +x;
|
|
2475
|
-
}
|
|
2476
|
-
var unit = [0, 1];
|
|
2477
|
-
function identity(x) {
|
|
2478
|
-
return x;
|
|
2479
|
-
}
|
|
2480
|
-
function normalize(a, b) {
|
|
2481
|
-
return (b -= a = +a) ? function(x) {
|
|
2482
|
-
return (x - a) / b;
|
|
2483
|
-
} : constants(isNaN(b) ? NaN : 0.5);
|
|
2484
|
-
}
|
|
2485
|
-
function clamper(a, b) {
|
|
2486
|
-
var t;
|
|
2487
|
-
if (a > b) t = a, a = b, b = t;
|
|
2488
|
-
return function(x) {
|
|
2489
|
-
return Math.max(a, Math.min(b, x));
|
|
2490
|
-
};
|
|
2491
|
-
}
|
|
2492
|
-
function bimap(domain, range, interpolate2) {
|
|
2493
|
-
var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
|
|
2494
|
-
if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate2(r1, r0);
|
|
2495
|
-
else d0 = normalize(d0, d1), r0 = interpolate2(r0, r1);
|
|
2496
|
-
return function(x) {
|
|
2497
|
-
return r0(d0(x));
|
|
2498
|
-
};
|
|
2499
|
-
}
|
|
2500
|
-
function polymap(domain, range, interpolate2) {
|
|
2501
|
-
var j = Math.min(domain.length, range.length) - 1, d = new Array(j), r = new Array(j), i = -1;
|
|
2502
|
-
if (domain[j] < domain[0]) {
|
|
2503
|
-
domain = domain.slice().reverse();
|
|
2504
|
-
range = range.slice().reverse();
|
|
2505
|
-
}
|
|
2506
|
-
while (++i < j) {
|
|
2507
|
-
d[i] = normalize(domain[i], domain[i + 1]);
|
|
2508
|
-
r[i] = interpolate2(range[i], range[i + 1]);
|
|
2509
|
-
}
|
|
2510
|
-
return function(x) {
|
|
2511
|
-
var i2 = bisectRight(domain, x, 1, j) - 1;
|
|
2512
|
-
return r[i2](d[i2](x));
|
|
2513
|
-
};
|
|
2514
|
-
}
|
|
2515
|
-
function copy(source, target) {
|
|
2516
|
-
return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown());
|
|
2517
|
-
}
|
|
2518
|
-
function transformer() {
|
|
2519
|
-
var domain = unit, range = unit, interpolate2 = interpolate$1, transform, untransform, unknown, clamp = identity, piecewise, output, input;
|
|
2520
|
-
function rescale() {
|
|
2521
|
-
var n = Math.min(domain.length, range.length);
|
|
2522
|
-
if (clamp !== identity) clamp = clamper(domain[0], domain[n - 1]);
|
|
2523
|
-
piecewise = n > 2 ? polymap : bimap;
|
|
2524
|
-
output = input = null;
|
|
2525
|
-
return scale;
|
|
2526
|
-
}
|
|
2527
|
-
function scale(x) {
|
|
2528
|
-
return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate2)))(transform(clamp(x)));
|
|
2529
|
-
}
|
|
2530
|
-
scale.invert = function(y) {
|
|
2531
|
-
return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y)));
|
|
2532
|
-
};
|
|
2533
|
-
scale.domain = function(_) {
|
|
2534
|
-
return arguments.length ? (domain = Array.from(_, number), rescale()) : domain.slice();
|
|
2535
|
-
};
|
|
2536
|
-
scale.range = function(_) {
|
|
2537
|
-
return arguments.length ? (range = Array.from(_), rescale()) : range.slice();
|
|
2538
|
-
};
|
|
2539
|
-
scale.rangeRound = function(_) {
|
|
2540
|
-
return range = Array.from(_), interpolate2 = interpolateRound, rescale();
|
|
2541
|
-
};
|
|
2542
|
-
scale.clamp = function(_) {
|
|
2543
|
-
return arguments.length ? (clamp = _ ? true : identity, rescale()) : clamp !== identity;
|
|
2544
|
-
};
|
|
2545
|
-
scale.interpolate = function(_) {
|
|
2546
|
-
return arguments.length ? (interpolate2 = _, rescale()) : interpolate2;
|
|
2547
|
-
};
|
|
2548
|
-
scale.unknown = function(_) {
|
|
2549
|
-
return arguments.length ? (unknown = _, scale) : unknown;
|
|
2550
|
-
};
|
|
2551
|
-
return function(t, u) {
|
|
2552
|
-
transform = t, untransform = u;
|
|
2553
|
-
return rescale();
|
|
2554
|
-
};
|
|
2555
|
-
}
|
|
2556
|
-
function continuous() {
|
|
2557
|
-
return transformer()(identity, identity);
|
|
2558
|
-
}
|
|
2559
|
-
function tickFormat(start2, stop, count, specifier) {
|
|
2560
|
-
var step = tickStep(start2, stop, count), precision;
|
|
2561
|
-
specifier = formatSpecifier(specifier == null ? ",f" : specifier);
|
|
2562
|
-
switch (specifier.type) {
|
|
2563
|
-
case "s": {
|
|
2564
|
-
var value = Math.max(Math.abs(start2), Math.abs(stop));
|
|
2565
|
-
if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision;
|
|
2566
|
-
return formatPrefix(specifier, value);
|
|
2567
|
-
}
|
|
2568
|
-
case "":
|
|
2569
|
-
case "e":
|
|
2570
|
-
case "g":
|
|
2571
|
-
case "p":
|
|
2572
|
-
case "r": {
|
|
2573
|
-
if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start2), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e");
|
|
2574
|
-
break;
|
|
2575
|
-
}
|
|
2576
|
-
case "f":
|
|
2577
|
-
case "%": {
|
|
2578
|
-
if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2;
|
|
2579
|
-
break;
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
return format(specifier);
|
|
2583
|
-
}
|
|
2584
|
-
function linearish(scale) {
|
|
2585
|
-
var domain = scale.domain;
|
|
2586
|
-
scale.ticks = function(count) {
|
|
2587
|
-
var d = domain();
|
|
2588
|
-
return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
|
|
2589
|
-
};
|
|
2590
|
-
scale.tickFormat = function(count, specifier) {
|
|
2591
|
-
var d = domain();
|
|
2592
|
-
return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier);
|
|
2593
|
-
};
|
|
2594
|
-
scale.nice = function(count) {
|
|
2595
|
-
if (count == null) count = 10;
|
|
2596
|
-
var d = domain();
|
|
2597
|
-
var i0 = 0;
|
|
2598
|
-
var i1 = d.length - 1;
|
|
2599
|
-
var start2 = d[i0];
|
|
2600
|
-
var stop = d[i1];
|
|
2601
|
-
var prestep;
|
|
2602
|
-
var step;
|
|
2603
|
-
var maxIter = 10;
|
|
2604
|
-
if (stop < start2) {
|
|
2605
|
-
step = start2, start2 = stop, stop = step;
|
|
2606
|
-
step = i0, i0 = i1, i1 = step;
|
|
2607
|
-
}
|
|
2608
|
-
while (maxIter-- > 0) {
|
|
2609
|
-
step = tickIncrement(start2, stop, count);
|
|
2610
|
-
if (step === prestep) {
|
|
2611
|
-
d[i0] = start2;
|
|
2612
|
-
d[i1] = stop;
|
|
2613
|
-
return domain(d);
|
|
2614
|
-
} else if (step > 0) {
|
|
2615
|
-
start2 = Math.floor(start2 / step) * step;
|
|
2616
|
-
stop = Math.ceil(stop / step) * step;
|
|
2617
|
-
} else if (step < 0) {
|
|
2618
|
-
start2 = Math.ceil(start2 * step) / step;
|
|
2619
|
-
stop = Math.floor(stop * step) / step;
|
|
2620
|
-
} else {
|
|
2621
|
-
break;
|
|
2622
|
-
}
|
|
2623
|
-
prestep = step;
|
|
2624
|
-
}
|
|
2625
|
-
return scale;
|
|
2626
|
-
};
|
|
2627
|
-
return scale;
|
|
2628
|
-
}
|
|
2629
|
-
function linear() {
|
|
2630
|
-
var scale = continuous();
|
|
2631
|
-
scale.copy = function() {
|
|
2632
|
-
return copy(scale, linear());
|
|
2633
|
-
};
|
|
2634
|
-
initRange.apply(scale, arguments);
|
|
2635
|
-
return linearish(scale);
|
|
2636
|
-
}
|
|
2637
|
-
function Transform(k, x, y) {
|
|
2638
|
-
this.k = k;
|
|
2639
|
-
this.x = x;
|
|
2640
|
-
this.y = y;
|
|
2641
|
-
}
|
|
2642
|
-
Transform.prototype = {
|
|
2643
|
-
constructor: Transform,
|
|
2644
|
-
scale: function(k) {
|
|
2645
|
-
return k === 1 ? this : new Transform(this.k * k, this.x, this.y);
|
|
2646
|
-
},
|
|
2647
|
-
translate: function(x, y) {
|
|
2648
|
-
return x === 0 & y === 0 ? this : new Transform(this.k, this.x + this.k * x, this.y + this.k * y);
|
|
2649
|
-
},
|
|
2650
|
-
apply: function(point) {
|
|
2651
|
-
return [point[0] * this.k + this.x, point[1] * this.k + this.y];
|
|
2652
|
-
},
|
|
2653
|
-
applyX: function(x) {
|
|
2654
|
-
return x * this.k + this.x;
|
|
2655
|
-
},
|
|
2656
|
-
applyY: function(y) {
|
|
2657
|
-
return y * this.k + this.y;
|
|
2658
|
-
},
|
|
2659
|
-
invert: function(location) {
|
|
2660
|
-
return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
|
|
2661
|
-
},
|
|
2662
|
-
invertX: function(x) {
|
|
2663
|
-
return (x - this.x) / this.k;
|
|
2664
|
-
},
|
|
2665
|
-
invertY: function(y) {
|
|
2666
|
-
return (y - this.y) / this.k;
|
|
2667
|
-
},
|
|
2668
|
-
rescaleX: function(x) {
|
|
2669
|
-
return x.copy().domain(x.range().map(this.invertX, this).map(x.invert, x));
|
|
2670
|
-
},
|
|
2671
|
-
rescaleY: function(y) {
|
|
2672
|
-
return y.copy().domain(y.range().map(this.invertY, this).map(y.invert, y));
|
|
2673
|
-
},
|
|
2674
|
-
toString: function() {
|
|
2675
|
-
return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
|
|
2676
|
-
}
|
|
2677
|
-
};
|
|
2678
|
-
Transform.prototype;
|
|
2679
|
-
const oob = {
|
|
2680
|
-
censor: oob_censor,
|
|
2681
|
-
squish(value, { min, max }) {
|
|
2682
|
-
if (!isFinite(value)) return value;
|
|
2683
|
-
if (value < min) return min;
|
|
2684
|
-
if (value > max) return max;
|
|
2685
|
-
return value;
|
|
2686
|
-
},
|
|
2687
|
-
squish_any: oob_squish_any,
|
|
2688
|
-
squish_infinite: oob_squish_infinite,
|
|
2689
|
-
discard(value, { min, max }) {
|
|
2690
|
-
if (value < min || value > max) return null;
|
|
2691
|
-
return value;
|
|
2692
|
-
}
|
|
2693
|
-
};
|
|
2694
|
-
function custom_scale(func, { title, ...etc } = {}) {
|
|
2695
|
-
return Object.assign(function(arr) {
|
|
2696
|
-
return arr.map(func);
|
|
2697
|
-
}, { title }, etc);
|
|
2698
|
-
}
|
|
2699
|
-
function manual_scale({
|
|
2700
|
-
values = {},
|
|
2701
|
-
na_value = null,
|
|
2702
|
-
title,
|
|
2703
|
-
...etc
|
|
2704
|
-
} = {}) {
|
|
2705
|
-
let fn;
|
|
2706
|
-
if (Array.isArray(values)) {
|
|
2707
|
-
fn = function(arr) {
|
|
2708
|
-
return arr.map((v) => values[+v] ?? na_value);
|
|
2709
|
-
};
|
|
2710
|
-
} else {
|
|
2711
|
-
fn = function(arr) {
|
|
2712
|
-
return arr.map((v) => values[v] ?? na_value);
|
|
2713
|
-
};
|
|
2714
|
-
}
|
|
2715
|
-
return Object.assign(fn, { title }, etc);
|
|
2716
|
-
}
|
|
2717
|
-
function continuous_scale({
|
|
2718
|
-
limits,
|
|
2719
|
-
oob: oob2 = oob_censor,
|
|
2720
|
-
range = [0, 1],
|
|
2721
|
-
na_value = null,
|
|
2722
|
-
null_value = null,
|
|
2723
|
-
title,
|
|
2724
|
-
...etc
|
|
2725
|
-
} = {}) {
|
|
2726
|
-
let fn = function(arr) {
|
|
2727
|
-
let scale_min = this?.limits?.min ?? this?.limits?.[0] ?? arr.extent?.[0], scale_max = this?.limits?.max ?? this?.limits?.[1] ?? arr.extent?.[1], scale_interval = scale_max - scale_min, range_min = range?.min ?? range[0], range_max = range?.max ?? range[1], range_interval = range_max - range_min;
|
|
2728
|
-
return arr.map((v) => {
|
|
2729
|
-
v = this.oob(v, { min: scale_min, max: scale_max });
|
|
2730
|
-
if (v === null) return null_value;
|
|
2731
|
-
if (isNaN(v)) return na_value;
|
|
2732
|
-
return range_min + (v - scale_min) / scale_interval * range_interval;
|
|
2733
|
-
});
|
|
2734
|
-
};
|
|
2735
|
-
return Object.assign(fn, { title, limits, oob: oob2 }, etc);
|
|
2736
|
-
}
|
|
2737
|
-
function identity_scale_number({ title, ...etc } = {}) {
|
|
2738
|
-
return Object.assign(function(arr) {
|
|
2739
|
-
return arr.map((v) => +v);
|
|
2740
|
-
}, { asis: true, title }, etc);
|
|
2741
|
-
}
|
|
2742
|
-
function identity_scale_string({ title, ...etc } = {}) {
|
|
2743
|
-
return Object.assign(function(arr) {
|
|
2744
|
-
return arr.map((v) => String(v ?? ""));
|
|
2745
|
-
}, { asis: true, title }, etc);
|
|
2746
|
-
}
|
|
2747
|
-
function palette_scale_hue({
|
|
2748
|
-
h = [15, 375],
|
|
2749
|
-
c = 100,
|
|
2750
|
-
l = 65,
|
|
2751
|
-
h_start = 0,
|
|
2752
|
-
direction = 1,
|
|
2753
|
-
limits,
|
|
2754
|
-
oob: oob2 = oob_censor,
|
|
2755
|
-
na_value = "#7f7f7f",
|
|
2756
|
-
null_value = null,
|
|
2757
|
-
title,
|
|
2758
|
-
...etc
|
|
2759
|
-
} = {}) {
|
|
2760
|
-
let fn = function(arr) {
|
|
2761
|
-
let scale_min = this?.limits?.min ?? this?.limits?.[0] ?? arr.extent?.[0], scale_max = this?.limits?.max ?? this?.limits?.[1] ?? arr.extent?.[1], scale_interval = scale_max - scale_min, h_min = h?.min ?? h[0], h_max = h?.max ?? h[1], h_interval = h_max - h_min;
|
|
2762
|
-
return arr.map((v) => {
|
|
2763
|
-
v = this.oob(v, { min: scale_min, max: scale_max });
|
|
2764
|
-
if (v === null) return null_value;
|
|
2765
|
-
if (isNaN(v)) return na_value;
|
|
2766
|
-
return hcl(h_start + h_min + h_interval * (v - scale_min) / scale_interval * direction, c, l).toString();
|
|
2767
|
-
});
|
|
2768
|
-
};
|
|
2769
|
-
return Object.assign(fn, { title, limits, oob: oob2 }, etc);
|
|
2770
|
-
}
|
|
2771
|
-
function palette_scale_manual({
|
|
2772
|
-
values,
|
|
2773
|
-
na_value = "#7f7f7f",
|
|
2774
|
-
title,
|
|
2775
|
-
...etc
|
|
2776
|
-
} = {}) {
|
|
2777
|
-
return manual_scale({ values, na_value, title, ...etc });
|
|
2778
|
-
}
|
|
2779
|
-
function palette_scale_gradient({
|
|
2780
|
-
low = "#132B43",
|
|
2781
|
-
high = "#56B1F7",
|
|
2782
|
-
limits,
|
|
2783
|
-
oob: oob2 = oob_censor,
|
|
2784
|
-
na_value = "#7f7f7f",
|
|
2785
|
-
null_value = null,
|
|
2786
|
-
title,
|
|
2787
|
-
...etc
|
|
2788
|
-
} = {}) {
|
|
2789
|
-
let fn = function(arr) {
|
|
2790
|
-
let scale_min = this?.limits?.min ?? this?.limits?.[0] ?? arr.extent?.[0], scale_max = this?.limits?.max ?? this?.limits?.[1] ?? arr.extent?.[1], scale = lab(low, high);
|
|
2791
|
-
return arr.map((v) => {
|
|
2792
|
-
v = this.oob(v, { min: scale_min, max: scale_max });
|
|
2793
|
-
if (v === null) return null_value;
|
|
2794
|
-
if (isNaN(v)) return na_value;
|
|
2795
|
-
if (scale_min === scale_max) return scale(0.5);
|
|
2796
|
-
if (v > scale_max) return high;
|
|
2797
|
-
if (v < scale_min) return low;
|
|
2798
|
-
return scale((v - scale_min) / (scale_max - scale_min));
|
|
2799
|
-
});
|
|
2800
|
-
};
|
|
2801
|
-
return Object.assign(fn, { title, limits, oob: oob2 }, etc);
|
|
2802
|
-
}
|
|
2803
|
-
function palette_scale_gradient2({
|
|
2804
|
-
low = "#832424",
|
|
2805
|
-
mid = "white",
|
|
2806
|
-
high = "#3A3A98",
|
|
2807
|
-
midpoint = 0,
|
|
2808
|
-
limits,
|
|
2809
|
-
oob: oob2 = oob_censor,
|
|
2810
|
-
na_value = "#7f7f7f",
|
|
2811
|
-
null_value = null,
|
|
2812
|
-
title,
|
|
2813
|
-
...etc
|
|
2814
|
-
} = {}) {
|
|
2815
|
-
let fn = function(arr) {
|
|
2816
|
-
let scale_min = this?.limits?.min ?? this?.limits?.[0] ?? arr.extent?.[0], scale_max = this?.limits?.max ?? this?.limits?.[1] ?? arr.extent?.[1], scale_mid = midpoint ?? (scale_min + scale_max) / 2, scale_low = lab(low, mid), scale_high = lab(mid, high);
|
|
2817
|
-
return arr.map((v) => {
|
|
2818
|
-
v = this.oob(v, { min: scale_min, max: scale_max });
|
|
2819
|
-
if (v === null) return null_value;
|
|
2820
|
-
if (isNaN(v)) return na_value;
|
|
2821
|
-
if (v < scale_mid) {
|
|
2822
|
-
return scale_low((v - scale_min) / (scale_mid - scale_min));
|
|
2823
|
-
} else {
|
|
2824
|
-
return scale_high((v - scale_mid) / (scale_max - scale_mid));
|
|
2825
|
-
}
|
|
2826
|
-
});
|
|
2827
|
-
};
|
|
2828
|
-
return Object.assign(fn, { title, limits, oob: oob2 }, etc);
|
|
2829
|
-
}
|
|
2830
|
-
function palette_scale_gradientn({
|
|
2831
|
-
colors = [],
|
|
2832
|
-
values,
|
|
2833
|
-
anchors,
|
|
2834
|
-
limits,
|
|
2835
|
-
oob: oob2 = oob_censor,
|
|
2836
|
-
na_value = "#7f7f7f",
|
|
2837
|
-
null_value = null,
|
|
2838
|
-
title,
|
|
2839
|
-
...etc
|
|
2840
|
-
} = {}) {
|
|
2841
|
-
let fn = function(arr) {
|
|
2842
|
-
let scale_min = this?.limits?.min ?? this?.limits?.[0] ?? arr.extent?.[0], scale_max = this?.limits?.max ?? this?.limits?.[1] ?? arr.extent?.[1];
|
|
2843
|
-
let domain = anchors;
|
|
2844
|
-
if (domain == null && values != null)
|
|
2845
|
-
domain = values.map((v) => scale_min + (scale_max - scale_min) * v);
|
|
2846
|
-
if (domain == null)
|
|
2847
|
-
domain = Array(colors.length).fill(0).map((_, i) => scale_min + (scale_max - scale_min) * i / (colors.length - 1));
|
|
2848
|
-
let scale = linear(domain, colors);
|
|
2849
|
-
return arr.map((v) => {
|
|
2850
|
-
v = this.oob(v, { min: scale_min, max: scale_max });
|
|
2851
|
-
if (v === null) return null_value;
|
|
2852
|
-
if (isNaN(v)) return na_value;
|
|
2853
|
-
return scale(v);
|
|
2854
|
-
});
|
|
2855
|
-
};
|
|
2856
|
-
return Object.assign(fn, { title, limits, oob: oob2 }, etc);
|
|
2857
|
-
}
|
|
2858
|
-
function palette_scale_auto({
|
|
2859
|
-
limits,
|
|
2860
|
-
oob: oob2 = oob_censor,
|
|
2861
|
-
title,
|
|
2862
|
-
...etc
|
|
2863
|
-
} = {}) {
|
|
2864
|
-
let scale_hue = palette_scale_hue(), scale_gradient = palette_scale_gradient();
|
|
2865
|
-
let fn = function(arr) {
|
|
2866
|
-
if (arr.level != null) {
|
|
2867
|
-
return scale_hue.call(this, arr);
|
|
2868
|
-
} else {
|
|
2869
|
-
return scale_gradient.call(this, arr);
|
|
2870
|
-
}
|
|
2871
|
-
};
|
|
2872
|
-
return Object.assign(fn, { title, limits, oob: oob2 }, etc);
|
|
2873
|
-
}
|
|
2874
|
-
function palette_scale_dynamic({
|
|
2875
|
-
discrete,
|
|
2876
|
-
continuous: continuous2,
|
|
2877
|
-
limits,
|
|
2878
|
-
oob: oob2 = oob_censor,
|
|
2879
|
-
title,
|
|
2880
|
-
...etc
|
|
2881
|
-
} = {}) {
|
|
2882
|
-
if (discrete == null) discrete = palette_scale_hue();
|
|
2883
|
-
if (continuous2 == null) continuous2 = palette_scale_gradient();
|
|
2884
|
-
let fn = function(arr) {
|
|
2885
|
-
if (arr.level != null) {
|
|
2886
|
-
return discrete.call(this, arr);
|
|
2887
|
-
} else {
|
|
2888
|
-
return continuous2.call(this, arr);
|
|
2889
|
-
}
|
|
2890
|
-
};
|
|
2891
|
-
return Object.assign(fn, { title, limits, oob: oob2 }, etc);
|
|
2892
|
-
}
|
|
2893
|
-
function shape_scale_discrete({ title, ...etc } = {}) {
|
|
2894
|
-
let shapes = ["circle", "square", "triangle", "diamond", "plus"];
|
|
2895
|
-
let fn = function(arr) {
|
|
2896
|
-
return arr.map((v) => shapes[+v]);
|
|
2897
|
-
};
|
|
2898
|
-
return Object.assign(fn, { title }, etc);
|
|
2899
|
-
}
|
|
2900
|
-
function linetype_scale_discrete({ title, ...etc } = {}) {
|
|
2901
|
-
let linetypes = [
|
|
2902
|
-
"solid",
|
|
2903
|
-
"22",
|
|
2904
|
-
"42",
|
|
2905
|
-
"44",
|
|
2906
|
-
"13",
|
|
2907
|
-
"1343",
|
|
2908
|
-
"73",
|
|
2909
|
-
"2262",
|
|
2910
|
-
"12223242",
|
|
2911
|
-
"F282",
|
|
2912
|
-
"F4448444",
|
|
2913
|
-
"224282F2",
|
|
2914
|
-
"F1"
|
|
2915
|
-
];
|
|
2916
|
-
let fn = function(arr) {
|
|
2917
|
-
return arr.map((v) => linetypes[+v]);
|
|
2918
|
-
};
|
|
2919
|
-
return Object.assign(fn, { title }, etc);
|
|
2920
|
-
}
|
|
2921
|
-
const palette_scales = {
|
|
2922
|
-
identity: ({ title, ...etc } = {}) => identity_scale_string({ legend: false, title, ...etc }),
|
|
2923
|
-
discrete: palette_scale_hue,
|
|
2924
|
-
hue: palette_scale_hue,
|
|
2925
|
-
manual: palette_scale_manual,
|
|
2926
|
-
continuous: palette_scale_gradient,
|
|
2927
|
-
gradient: palette_scale_gradient,
|
|
2928
|
-
gradient2: palette_scale_gradient2,
|
|
2929
|
-
gradientn: palette_scale_gradientn,
|
|
2930
|
-
dynamic: palette_scale_dynamic,
|
|
2931
|
-
auto: palette_scale_auto,
|
|
2932
|
-
custom: custom_scale,
|
|
2933
|
-
default: palette_scale_auto
|
|
2934
|
-
};
|
|
2935
|
-
const vvscale = {
|
|
2936
|
-
color: palette_scales,
|
|
2937
|
-
stroke: palette_scales,
|
|
2938
|
-
fill: palette_scales,
|
|
2939
|
-
alpha: {
|
|
2940
|
-
continuous: continuous_scale,
|
|
2941
|
-
custom: custom_scale,
|
|
2942
|
-
default: ({ title, ...etc } = {}) => continuous_scale({ range: [0.1, 1], title, ...etc })
|
|
2943
|
-
},
|
|
2944
|
-
size: {
|
|
2945
|
-
identity: ({ title, ...etc } = {}) => identity_scale_number({ legend: false, title, ...etc }),
|
|
2946
|
-
continuous: continuous_scale,
|
|
2947
|
-
custom: custom_scale,
|
|
2948
|
-
default: ({ title, ...etc } = {}) => continuous_scale({ range: [1, 6], title, ...etc })
|
|
2949
|
-
},
|
|
2950
|
-
linewidth: {
|
|
2951
|
-
identity: ({ title, ...etc } = {}) => identity_scale_number({ legend: false, title, ...etc }),
|
|
2952
|
-
continuous: continuous_scale,
|
|
2953
|
-
manual: manual_scale,
|
|
2954
|
-
custom: custom_scale,
|
|
2955
|
-
default: ({ title, ...etc } = {}) => continuous_scale({ range: [1, 6], title, ...etc })
|
|
2956
|
-
},
|
|
2957
|
-
linetype: {
|
|
2958
|
-
identity: ({ title, ...etc } = {}) => identity_scale_string({ legend: false, title, ...etc }),
|
|
2959
|
-
discrete: linetype_scale_discrete,
|
|
2960
|
-
default: linetype_scale_discrete,
|
|
2961
|
-
custom: custom_scale
|
|
2962
|
-
},
|
|
2963
|
-
shape: {
|
|
2964
|
-
identity: ({ title, ...etc } = {}) => identity_scale_string({ legend: false, title, ...etc }),
|
|
2965
|
-
discrete: shape_scale_discrete,
|
|
2966
|
-
default: shape_scale_discrete,
|
|
2967
|
-
custom: custom_scale
|
|
2968
|
-
}
|
|
2969
|
-
};
|
|
2970
|
-
export {
|
|
2971
|
-
vvscale as default,
|
|
2972
|
-
oob
|
|
2973
|
-
};
|