@plotdb/chart 3.5.0 → 3.6.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/CHANGELOG.md +20 -0
- package/bundle.css +59 -0
- package/bundle.js +4545 -0
- package/bundle.min.css +1 -0
- package/bundle.min.js +1 -0
- package/index.js +32 -10
- package/index.min.js +1 -1
- package/package.json +1 -1
- package/utils/anim.js +428 -0
- package/utils/anim.min.js +1 -0
- package/utils/brush.js +304 -0
- package/utils/brush.min.js +1 -0
- package/utils/debounce.js +86 -0
- package/utils/debounce.min.js +1 -0
- package/utils/format.js +266 -5
- package/utils/format.min.js +1 -1
- package/utils/scale.js +228 -0
- package/utils/scale.min.js +1 -0
package/bundle.js
ADDED
|
@@ -0,0 +1,4545 @@
|
|
|
1
|
+
(function(){
|
|
2
|
+
var debounce;
|
|
3
|
+
debounce = function(f, o){
|
|
4
|
+
var ref$, l, ret;
|
|
5
|
+
if (typeof f === 'number' && !(o != null)) {
|
|
6
|
+
return new Promise(function(res){
|
|
7
|
+
return setTimeout(res, f);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
if (typeof o === 'function') {
|
|
11
|
+
ref$ = [o, f], f = ref$[0], o = ref$[1];
|
|
12
|
+
}
|
|
13
|
+
o = o || {};
|
|
14
|
+
ref$ = typeof f === 'object'
|
|
15
|
+
? [f.func, f]
|
|
16
|
+
: [
|
|
17
|
+
f, {
|
|
18
|
+
delay: typeof o === 'object' ? o.delay || 750 : o
|
|
19
|
+
}
|
|
20
|
+
], f = ref$[0], o = ref$[1];
|
|
21
|
+
l = {};
|
|
22
|
+
ret = function(){
|
|
23
|
+
var args, res$, i$, to$, used, delay, p, this$ = this;
|
|
24
|
+
res$ = [];
|
|
25
|
+
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
|
|
26
|
+
res$.push(arguments[i$]);
|
|
27
|
+
}
|
|
28
|
+
args = res$;
|
|
29
|
+
used = false;
|
|
30
|
+
delay = ret.delay.value || o.delay || 750;
|
|
31
|
+
ret.delay.value = 0;
|
|
32
|
+
p = new Promise(function(res, rej){
|
|
33
|
+
if (used) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (l.h) {
|
|
37
|
+
ret.clear();
|
|
38
|
+
}
|
|
39
|
+
l.res = res;
|
|
40
|
+
l.rej = rej;
|
|
41
|
+
return l.h = setTimeout(function(){
|
|
42
|
+
var r;
|
|
43
|
+
r = f.apply(this$, args);
|
|
44
|
+
if (r && typeof r.then === 'function') {
|
|
45
|
+
r.then(function(){
|
|
46
|
+
var a, res$, i$, to$;
|
|
47
|
+
res$ = [];
|
|
48
|
+
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
|
|
49
|
+
res$.push(arguments[i$]);
|
|
50
|
+
}
|
|
51
|
+
a = res$;
|
|
52
|
+
return res.apply(null, a);
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
res(r);
|
|
56
|
+
}
|
|
57
|
+
return l.res = null, l.rej = null, l.h = 0, l;
|
|
58
|
+
}, delay);
|
|
59
|
+
});
|
|
60
|
+
p.now = function(){
|
|
61
|
+
used = true;
|
|
62
|
+
ret.clear();
|
|
63
|
+
return f.apply(this$, args);
|
|
64
|
+
};
|
|
65
|
+
p.cancel = function(){
|
|
66
|
+
return ret.clear();
|
|
67
|
+
};
|
|
68
|
+
return p;
|
|
69
|
+
};
|
|
70
|
+
ret.clear = function(){
|
|
71
|
+
clearTimeout(l.h);
|
|
72
|
+
if (l.res) {
|
|
73
|
+
l.res(null);
|
|
74
|
+
}
|
|
75
|
+
return l.h = 0, l.res = null, l.rej = null, l;
|
|
76
|
+
};
|
|
77
|
+
ret.delay = function(it){
|
|
78
|
+
ret.delay.value = it;
|
|
79
|
+
return ret;
|
|
80
|
+
};
|
|
81
|
+
return ret;
|
|
82
|
+
};
|
|
83
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
84
|
+
(chart.utils || (chart.utils = {})).debounce = debounce;
|
|
85
|
+
}
|
|
86
|
+
var module = {exports: {}};
|
|
87
|
+
(function(){
|
|
88
|
+
var svgns, _np, _nparse, _snum, _isNumeric, _alignDim, _parseSubset, _rgb, bindScope, parent, aniloop, visibilityObserver, resizeObserver, withDefault, defaultConfig, chart;
|
|
89
|
+
svgns = "http://www.w3.org/2000/svg";
|
|
90
|
+
_np = function(lc){
|
|
91
|
+
var format, parts, numerals, index;
|
|
92
|
+
format = new Intl.NumberFormat(lc);
|
|
93
|
+
parts = format.formatToParts(12345.6);
|
|
94
|
+
numerals = Array.from({
|
|
95
|
+
length: 10
|
|
96
|
+
}).map(function(_, i){
|
|
97
|
+
return format.format(i);
|
|
98
|
+
});
|
|
99
|
+
index = new Map(numerals.map(function(d, i){
|
|
100
|
+
return [d, i];
|
|
101
|
+
}));
|
|
102
|
+
this._group = new RegExp("[" + parts.find(function(d){
|
|
103
|
+
return deepEq$(d.type, 'group', '===');
|
|
104
|
+
}).value + "]", 'g');
|
|
105
|
+
this._decimal = new RegExp("[" + parts.find(function(d){
|
|
106
|
+
return deepEq$(d.type, 'decimal', '===');
|
|
107
|
+
}).value + "]");
|
|
108
|
+
this._numeral = new RegExp("[" + numerals.join("") + "]", "g");
|
|
109
|
+
this._index = function(d){
|
|
110
|
+
return index.get(d);
|
|
111
|
+
};
|
|
112
|
+
return this;
|
|
113
|
+
};
|
|
114
|
+
_np = new _np("en-US");
|
|
115
|
+
_nparse = function(str){
|
|
116
|
+
str == null && (str = "");
|
|
117
|
+
str = (str + "").trim().replace(_np._group, "").replace(_np._decimal, '.').replace(_np._numeral, _np._index);
|
|
118
|
+
if (str) {
|
|
119
|
+
return +str;
|
|
120
|
+
} else {
|
|
121
|
+
return NaN;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
_snum = function(v){
|
|
125
|
+
if (typeof v === 'number') {
|
|
126
|
+
return v;
|
|
127
|
+
} else {
|
|
128
|
+
if ((!v && v !== 0) || isNaN(+v)) {
|
|
129
|
+
return 0;
|
|
130
|
+
} else {
|
|
131
|
+
return +v;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
_isNumeric = function(d){
|
|
136
|
+
d == null && (d = {});
|
|
137
|
+
return !!(/[RIT]/.exec(d.type || '') && !/[CN]/.exec(d.type || ''));
|
|
138
|
+
};
|
|
139
|
+
_alignDim = function(dim){
|
|
140
|
+
var ks, res$, k, i$, ref$, len$;
|
|
141
|
+
dim == null && (dim = {});
|
|
142
|
+
res$ = [];
|
|
143
|
+
for (k in dim) {
|
|
144
|
+
res$.push(k);
|
|
145
|
+
}
|
|
146
|
+
ks = res$;
|
|
147
|
+
for (i$ = 0, len$ = (ref$ = ['name', 'order']).length; i$ < len$; ++i$) {
|
|
148
|
+
k = ref$[i$];
|
|
149
|
+
if (dim[k] && !_isNumeric(dim[k])) {
|
|
150
|
+
return k;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return ks.filter(function(k){
|
|
154
|
+
return !_isNumeric(dim[k]);
|
|
155
|
+
})[0];
|
|
156
|
+
};
|
|
157
|
+
_parseSubset = function(){
|
|
158
|
+
var dim, kd, rows, hash, this$ = this;
|
|
159
|
+
dim = (this.mod || {}).dimension || {};
|
|
160
|
+
if (!this._subset) {
|
|
161
|
+
this.data.map(function(it){
|
|
162
|
+
var ref$;
|
|
163
|
+
return ref$ = it.subset, delete it.subset, ref$;
|
|
164
|
+
});
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
kd = _alignDim(dim);
|
|
168
|
+
rows = this._subset.map(function(r){
|
|
169
|
+
var ret, k, ref$, v, b;
|
|
170
|
+
ret = {};
|
|
171
|
+
for (k in ref$ = dim) {
|
|
172
|
+
v = ref$[k];
|
|
173
|
+
if (!(b = this$.binding[k])) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
ret[k] = !v.multiple
|
|
177
|
+
? r[b.key]
|
|
178
|
+
: (b.map
|
|
179
|
+
? b
|
|
180
|
+
: [b]).map(fn$);
|
|
181
|
+
if (_isNumeric(v)) {
|
|
182
|
+
ret[k] = Array.isArray(ret[k])
|
|
183
|
+
? ret[k].map(_snum)
|
|
184
|
+
: _snum(ret[k]);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return ret;
|
|
188
|
+
function fn$(it){
|
|
189
|
+
return r[it.key];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
hash = {};
|
|
193
|
+
if (kd) {
|
|
194
|
+
rows.map(function(r){
|
|
195
|
+
return hash[r[kd] + ""] = r;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
this.data.map(function(d, i){
|
|
199
|
+
var src, subset, k, ref$, v;
|
|
200
|
+
src = kd
|
|
201
|
+
? hash[d[kd] + ""]
|
|
202
|
+
: rows[i];
|
|
203
|
+
subset = {};
|
|
204
|
+
for (k in ref$ = dim) {
|
|
205
|
+
v = ref$[k];
|
|
206
|
+
if (!_isNumeric(v)) {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
subset[k] = v.multiple
|
|
210
|
+
? (d[k] || []).map(fn$)
|
|
211
|
+
: src ? _snum(src[k]) : 0;
|
|
212
|
+
}
|
|
213
|
+
return d.subset = subset;
|
|
214
|
+
function fn$(x, j){
|
|
215
|
+
if (src) {
|
|
216
|
+
return _snum((src[k] || [])[j]);
|
|
217
|
+
} else {
|
|
218
|
+
return 0;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
if ((((this.cfg || {}).common || {}).subset || {}).mode === 'shrink') {
|
|
223
|
+
return this.data.map(function(d){
|
|
224
|
+
var k, ref$, v, results$ = [];
|
|
225
|
+
for (k in ref$ = dim) {
|
|
226
|
+
v = ref$[k];
|
|
227
|
+
if (_isNumeric(v)) {
|
|
228
|
+
results$.push(d[k] = d.subset[k]);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return results$;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
_rgb = function(c){
|
|
236
|
+
var m, x, v;
|
|
237
|
+
if (typeof c !== 'string') {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
c = c.trim();
|
|
241
|
+
if (m = /^#([0-9a-f]{3})$/i.exec(c)) {
|
|
242
|
+
return (function(){
|
|
243
|
+
var i$, ref$, len$, results$ = [];
|
|
244
|
+
for (i$ = 0, len$ = (ref$ = m[1].split('')).length; i$ < len$; ++i$) {
|
|
245
|
+
x = ref$[i$];
|
|
246
|
+
results$.push(parseInt(x + x, 16));
|
|
247
|
+
}
|
|
248
|
+
return results$;
|
|
249
|
+
}());
|
|
250
|
+
}
|
|
251
|
+
if (m = /^#([0-9a-f]{6})$/i.exec(c)) {
|
|
252
|
+
return [0, 1, 2].map(function(i){
|
|
253
|
+
return parseInt(m[1].substr(i * 2, 2), 16);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
if (m = /^rgba?\(([^)]+)\)$/i.exec(c)) {
|
|
257
|
+
v = m[1].split(',').slice(0, 3).map(function(it){
|
|
258
|
+
return parseFloat(it.trim());
|
|
259
|
+
});
|
|
260
|
+
return v.length === 3 && v.every(function(it){
|
|
261
|
+
return !isNaN(it);
|
|
262
|
+
}) ? v : null;
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
265
|
+
};
|
|
266
|
+
bindScope = function(self, tbl, over){
|
|
267
|
+
var ret, k, ref$, f;
|
|
268
|
+
tbl == null && (tbl = {});
|
|
269
|
+
over == null && (over = {});
|
|
270
|
+
ret = {};
|
|
271
|
+
for (k in ref$ = import$(import$({}, tbl), over || {})) {
|
|
272
|
+
f = ref$[k];
|
|
273
|
+
ret[k] = typeof f === 'function' ? f.bind(self) : f;
|
|
274
|
+
}
|
|
275
|
+
return ret;
|
|
276
|
+
};
|
|
277
|
+
parent = function(n, s, e){
|
|
278
|
+
var m;
|
|
279
|
+
m = n;
|
|
280
|
+
while (n && n !== e) {
|
|
281
|
+
n = n.parentNode;
|
|
282
|
+
}
|
|
283
|
+
if (n !== e) {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
if (!s) {
|
|
287
|
+
return n;
|
|
288
|
+
}
|
|
289
|
+
n = m;
|
|
290
|
+
while (n && n !== e && (!n.matches || (n.matches && !n.matches(s)))) {
|
|
291
|
+
n = n.parentNode;
|
|
292
|
+
}
|
|
293
|
+
if (n === e && (!e.matches || !e.matches(s))) {
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
return n;
|
|
297
|
+
};
|
|
298
|
+
aniloop = function(){
|
|
299
|
+
this.running = false;
|
|
300
|
+
this.time = {
|
|
301
|
+
now: 0,
|
|
302
|
+
last: 0
|
|
303
|
+
};
|
|
304
|
+
this.fps(60);
|
|
305
|
+
this.evtHandler = {};
|
|
306
|
+
return this;
|
|
307
|
+
};
|
|
308
|
+
aniloop.prototype = import$(Object.create(Object.prototype), {
|
|
309
|
+
on: function(n, cb){
|
|
310
|
+
var this$ = this;
|
|
311
|
+
return (Array.isArray(n)
|
|
312
|
+
? n
|
|
313
|
+
: [n]).map(function(n){
|
|
314
|
+
var ref$;
|
|
315
|
+
return ((ref$ = this$.evtHandler)[n] || (ref$[n] = [])).push(cb);
|
|
316
|
+
});
|
|
317
|
+
},
|
|
318
|
+
fire: function(n){
|
|
319
|
+
var v, res$, i$, to$, ref$, len$, cb, results$ = [];
|
|
320
|
+
res$ = [];
|
|
321
|
+
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
|
|
322
|
+
res$.push(arguments[i$]);
|
|
323
|
+
}
|
|
324
|
+
v = res$;
|
|
325
|
+
for (i$ = 0, len$ = (ref$ = this.evtHandler[n] || []).length; i$ < len$; ++i$) {
|
|
326
|
+
cb = ref$[i$];
|
|
327
|
+
results$.push(cb.apply(this, v));
|
|
328
|
+
}
|
|
329
|
+
return results$;
|
|
330
|
+
},
|
|
331
|
+
reset: function(){
|
|
332
|
+
return this.time = {
|
|
333
|
+
now: 0
|
|
334
|
+
};
|
|
335
|
+
},
|
|
336
|
+
setTime: function(t){
|
|
337
|
+
return this.time.now = t;
|
|
338
|
+
},
|
|
339
|
+
getTime: function(){
|
|
340
|
+
return this.time.now;
|
|
341
|
+
},
|
|
342
|
+
isRunning: function(){
|
|
343
|
+
return this.running;
|
|
344
|
+
},
|
|
345
|
+
toggle: function(it){
|
|
346
|
+
if (it != null) {
|
|
347
|
+
this.running = !it;
|
|
348
|
+
}
|
|
349
|
+
if (this.running) {
|
|
350
|
+
return this.pause();
|
|
351
|
+
} else {
|
|
352
|
+
return this.run();
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
pause: function(){
|
|
356
|
+
return this.running = false;
|
|
357
|
+
},
|
|
358
|
+
render: function(dt){
|
|
359
|
+
dt == null && (dt = 0);
|
|
360
|
+
return this.fire('tick', this.time.now, dt);
|
|
361
|
+
},
|
|
362
|
+
run: function(fps){
|
|
363
|
+
var this$ = this;
|
|
364
|
+
if (fps != null) {
|
|
365
|
+
this.fps(fps);
|
|
366
|
+
}
|
|
367
|
+
if (this.running) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
this.running = true;
|
|
371
|
+
return requestAnimationFrame(function(t){
|
|
372
|
+
return this$.handler(this$.time.last = t, true);
|
|
373
|
+
});
|
|
374
|
+
},
|
|
375
|
+
throttle: function(v){
|
|
376
|
+
v == null && (v = true);
|
|
377
|
+
return this.isThrottled = v;
|
|
378
|
+
},
|
|
379
|
+
fps: function(it){
|
|
380
|
+
if (!(it != null)) {
|
|
381
|
+
return this._fps_val;
|
|
382
|
+
}
|
|
383
|
+
this._fps_val = it > 0.01 ? it : 0.01;
|
|
384
|
+
return this._fps_delay = 1000 / this._fps_val;
|
|
385
|
+
},
|
|
386
|
+
handler: function(t, force){
|
|
387
|
+
var delay, ref$, dt, this$ = this;
|
|
388
|
+
force == null && (force = false);
|
|
389
|
+
if (!this.running) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
if (this.external && this.external()) {
|
|
393
|
+
this.time.last = t;
|
|
394
|
+
return requestAnimationFrame(function(t){
|
|
395
|
+
return this$.handler(t, false);
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
this.time.now = t;
|
|
399
|
+
delay = this.isThrottled
|
|
400
|
+
? (ref$ = this._fps_delay) > 1000 ? ref$ : 1000
|
|
401
|
+
: this._fps_delay;
|
|
402
|
+
if (force || (dt = this.time.now - this.time.last) >= delay) {
|
|
403
|
+
this.time.last = t;
|
|
404
|
+
this.render(force ? 0 : dt);
|
|
405
|
+
}
|
|
406
|
+
return requestAnimationFrame(function(t){
|
|
407
|
+
return this$.handler(t, false);
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
visibilityObserver = {
|
|
412
|
+
list: [],
|
|
413
|
+
init: function(){
|
|
414
|
+
var ref$, h, vc, this$ = this;
|
|
415
|
+
this.inited = true;
|
|
416
|
+
ref$ = document.hidden != null
|
|
417
|
+
? ['hidden', 'visibilitychange']
|
|
418
|
+
: document.msHidden != null
|
|
419
|
+
? ['hidden', 'visibilitychange']
|
|
420
|
+
: document.webkiHidden != null
|
|
421
|
+
? ['webkitHidden', 'webkitvisibilitychange']
|
|
422
|
+
: ['hidden', 'visibilitychange'], h = ref$[0], vc = ref$[1];
|
|
423
|
+
return document.addEventListener(vc, debounce(150, function(){
|
|
424
|
+
var th;
|
|
425
|
+
th = !!document[h];
|
|
426
|
+
return this$.list.map(function(it){
|
|
427
|
+
return it.throttle(th);
|
|
428
|
+
});
|
|
429
|
+
}, false));
|
|
430
|
+
},
|
|
431
|
+
add: function(aniloop){
|
|
432
|
+
if (!this.inited) {
|
|
433
|
+
this.init();
|
|
434
|
+
}
|
|
435
|
+
return this.list.push(aniloop);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
resizeObserver = {
|
|
439
|
+
wm: new WeakMap(),
|
|
440
|
+
ro: new ResizeObserver(function(list){
|
|
441
|
+
return list.map(function(n){
|
|
442
|
+
var ret;
|
|
443
|
+
ret = resizeObserver.wm.get(n.target);
|
|
444
|
+
return ret._resize();
|
|
445
|
+
});
|
|
446
|
+
}),
|
|
447
|
+
add: function(node, obj){
|
|
448
|
+
this.wm.set(node, obj);
|
|
449
|
+
return this.ro.observe(node);
|
|
450
|
+
},
|
|
451
|
+
'delete': function(it){
|
|
452
|
+
this.ro.unobserve(it);
|
|
453
|
+
return this.wm['delete'](it);
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
withDefault = function(cfg, defcfg, meta){
|
|
457
|
+
var _;
|
|
458
|
+
cfg == null && (cfg = {});
|
|
459
|
+
defcfg == null && (defcfg = {});
|
|
460
|
+
meta == null && (meta = {});
|
|
461
|
+
defcfg = JSON.parse(JSON.stringify(defcfg));
|
|
462
|
+
_ = function(cfg, defcfg, meta){
|
|
463
|
+
var k, v;
|
|
464
|
+
for (k in defcfg) {
|
|
465
|
+
v = defcfg[k];
|
|
466
|
+
if (!(cfg[k] != null)) {
|
|
467
|
+
cfg[k] = v;
|
|
468
|
+
} else if (typeof cfg[k] === 'object' && typeof v === 'object' && !(meta[k] && meta[k].type)) {
|
|
469
|
+
withDefault(cfg[k], defcfg[k], meta[k]);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return cfg;
|
|
473
|
+
};
|
|
474
|
+
return _(cfg, defcfg, meta);
|
|
475
|
+
};
|
|
476
|
+
defaultConfig = function(cfg){
|
|
477
|
+
var _;
|
|
478
|
+
_ = function(meta, ret){
|
|
479
|
+
var ctrls, that, id, v;
|
|
480
|
+
ret == null && (ret = {});
|
|
481
|
+
ctrls = (that = meta.child) ? that : meta;
|
|
482
|
+
for (id in meta) {
|
|
483
|
+
v = meta[id];
|
|
484
|
+
if (!v.type) {
|
|
485
|
+
_(v, ret[id] || (ret[id] = {}));
|
|
486
|
+
} else if (v['default']) {
|
|
487
|
+
ret[id] = v['default'];
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
return ret;
|
|
491
|
+
};
|
|
492
|
+
return _(cfg);
|
|
493
|
+
};
|
|
494
|
+
chart = function(opt){
|
|
495
|
+
var name, ref$, tbl, this$ = this;
|
|
496
|
+
opt == null && (opt = {});
|
|
497
|
+
this.root = typeof opt.root === 'string'
|
|
498
|
+
? document.querySelector(opt.root)
|
|
499
|
+
: opt.root;
|
|
500
|
+
this.useSample = opt.useSample != null ? opt.useSample : true;
|
|
501
|
+
this.autoSelect = opt.autoSelect != null ? opt.autoSelect : true;
|
|
502
|
+
this.forceInit = opt.forceInit ? opt.forceInit : false;
|
|
503
|
+
this.prepareSvg = opt.prepareSvg != null ? opt.prepareSvg : true;
|
|
504
|
+
this.layoutOpt = opt.layout != null ? opt.layout : true;
|
|
505
|
+
this.delayRender = opt.delayRender || false;
|
|
506
|
+
this.dataAccessor = opt.dataAccessor != null
|
|
507
|
+
? opt.dataAccessor
|
|
508
|
+
: function(it){
|
|
509
|
+
if (it) {
|
|
510
|
+
return it.data._raw;
|
|
511
|
+
} else {
|
|
512
|
+
return null;
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
this.data = [];
|
|
516
|
+
this.raw = opt.raw || null;
|
|
517
|
+
this.mod = opt.mod || {};
|
|
518
|
+
this.cfg = opt.config || {};
|
|
519
|
+
this.seed = opt.seed || Math.random();
|
|
520
|
+
this.binding = opt.binding || {};
|
|
521
|
+
this._normalizeBinding();
|
|
522
|
+
this.evtHandler = {};
|
|
523
|
+
this._subset = opt.subset || null;
|
|
524
|
+
for (name in ref$ = chart.scopes) {
|
|
525
|
+
tbl = ref$[name];
|
|
526
|
+
if (this[name] != null) {
|
|
527
|
+
throw new Error("[@plotdb/chart] scope name `" + name + "` is already taken.");
|
|
528
|
+
}
|
|
529
|
+
this[name] = bindScope(this, tbl, this.mod[name]);
|
|
530
|
+
}
|
|
531
|
+
if (this.local != null) {
|
|
532
|
+
throw new Error("[@plotdb/chart] scope name `local` is already taken.");
|
|
533
|
+
}
|
|
534
|
+
this.local = bindScope(this, {}, this.mod.local);
|
|
535
|
+
if ((chart.utils || (chart.utils = {})).anim && !(this.anim != null)) {
|
|
536
|
+
this.anim = new chart.utils.anim();
|
|
537
|
+
}
|
|
538
|
+
this.init = proxise.once(function(){
|
|
539
|
+
return this$._init();
|
|
540
|
+
});
|
|
541
|
+
this._resize = null;
|
|
542
|
+
this._inited = false;
|
|
543
|
+
if (this.autoSelect) {
|
|
544
|
+
this.root.addEventListener('click', this._select = function(e){
|
|
545
|
+
var p;
|
|
546
|
+
if (!(p = parent(e.target, '.data', this$.root))) {
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
return this$.fire('select', [{
|
|
550
|
+
data: this$.dataAccessor(p),
|
|
551
|
+
node: p
|
|
552
|
+
}]);
|
|
553
|
+
});
|
|
554
|
+
this.root.addEventListener('mouseover', this._hover = function(e){
|
|
555
|
+
var p;
|
|
556
|
+
if (!(p = parent(e.target, '.data', this$.root))) {
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
return this$.fire('hover', [{
|
|
560
|
+
data: this$.dataAccessor(p),
|
|
561
|
+
node: p
|
|
562
|
+
}]);
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
return this;
|
|
566
|
+
};
|
|
567
|
+
chart.prototype = import$(Object.create(Object.prototype), {
|
|
568
|
+
_init: function(){
|
|
569
|
+
var layoutRoot, ref$, r, p, this$ = this;
|
|
570
|
+
if (window.getComputedStyle(this.root).position === 'static') {
|
|
571
|
+
this.root.style.position = 'relative';
|
|
572
|
+
}
|
|
573
|
+
layoutRoot = this.layoutOpt ? typeof this.layoutOpt !== 'object'
|
|
574
|
+
? this.root.querySelector('.pdl-layout')
|
|
575
|
+
: typeof this.layoutOpt.root === 'string'
|
|
576
|
+
? this.root.querySelector(this.layoutOpt.root)
|
|
577
|
+
: this.layoutOpt.root ? this.layoutOpt.root : null : null;
|
|
578
|
+
if (this.prepareSvg && !(this.svg = this.root.querySelector('svg'))) {
|
|
579
|
+
this.svg = document.createElementNS(svgns, "svg");
|
|
580
|
+
ref$ = this.svg.style;
|
|
581
|
+
ref$.width = "100%";
|
|
582
|
+
ref$.height = "100%";
|
|
583
|
+
if (this.layoutOpt) {
|
|
584
|
+
if (!layoutRoot) {
|
|
585
|
+
console.error("[@plotdb/chart] layout enabled yet layout root isn't configured properly. ");
|
|
586
|
+
}
|
|
587
|
+
r = layoutRoot.querySelector('[data-type=render]');
|
|
588
|
+
if (!r) {
|
|
589
|
+
console.warn("[@plotdb/chart] prepareSvg and layout is configured at the same time,\nyet render container for layout is not found. svg is thus appended in the root.");
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
(r || this.root).appendChild(this.svg);
|
|
593
|
+
}
|
|
594
|
+
this._aniloop = new aniloop();
|
|
595
|
+
visibilityObserver.add(this._aniloop);
|
|
596
|
+
this._aniloop.on('tick', function(t, dt){
|
|
597
|
+
return this$.tick(t, dt);
|
|
598
|
+
});
|
|
599
|
+
if (this.anim) {
|
|
600
|
+
this._aniloop.external = function(){
|
|
601
|
+
return this$.anim.manual();
|
|
602
|
+
};
|
|
603
|
+
this.anim.on('step', function(t, dt){
|
|
604
|
+
if (!this$._aniloop.isRunning()) {
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
this$._aniloop.setTime(t);
|
|
608
|
+
return this$._aniloop.render(dt);
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
return p = Promise.resolve().then(function(){
|
|
612
|
+
var defcfg, ret;
|
|
613
|
+
this$.mod.config = withDefault(this$.mod.config || {}, chart.commonConfig);
|
|
614
|
+
this$._defcfg = defcfg = defaultConfig(this$.mod.config);
|
|
615
|
+
withDefault(this$.cfg, defcfg);
|
|
616
|
+
if (this$.raw && Array.isArray(this$.raw)) {
|
|
617
|
+
return {
|
|
618
|
+
raw: this$.raw,
|
|
619
|
+
binding: this$.binding
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
if (!this$.useSample || !this$.mod.sample) {
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
ret = this$.mod.sample.apply(this$);
|
|
626
|
+
return ret.then
|
|
627
|
+
? ret.then()
|
|
628
|
+
: Promise.resolve(ret);
|
|
629
|
+
}).then(function(it){
|
|
630
|
+
var ref$;
|
|
631
|
+
return this$.raw = (ref$ = it || {}).raw, this$.binding = ref$.binding, this$;
|
|
632
|
+
}).then(function(){
|
|
633
|
+
var ref$, _resizeLock, lock;
|
|
634
|
+
if (!this$.raw) {
|
|
635
|
+
this$.raw = [];
|
|
636
|
+
}
|
|
637
|
+
if (this$.layoutOpt) {
|
|
638
|
+
if (!(typeof layout != 'undefined' && layout !== null)) {
|
|
639
|
+
console.warn("[@plotdb/chart] layout-opt is set yet @plotdb/layout is not found.");
|
|
640
|
+
} else {
|
|
641
|
+
if (!layoutRoot) {
|
|
642
|
+
console.error("[@plotdb/chart] cannot determine root node for @plotdb/layout.");
|
|
643
|
+
console.error("[@plotdb/chart] config layout properly or disable layout by setting layout to false");
|
|
644
|
+
}
|
|
645
|
+
this$.layout = new layout(typeof this$.layoutOpt === 'object'
|
|
646
|
+
? (ref$ = import$({}, this$.layoutOpt), ref$.watchResize = false, ref$)
|
|
647
|
+
: {
|
|
648
|
+
root: layoutRoot,
|
|
649
|
+
watchResize: false
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
_resizeLock = proxise(function(){
|
|
654
|
+
resizeObserver.add(this$.root, this$);
|
|
655
|
+
return null;
|
|
656
|
+
});
|
|
657
|
+
this$._resize = function(){
|
|
658
|
+
return _resizeLock.resolve();
|
|
659
|
+
};
|
|
660
|
+
lock = _resizeLock();
|
|
661
|
+
if (this$.forceInit || !this$.root.offsetParent || window.getComputedStyle(this$.root).display === 'none' || (this$.root.offsetWidth && this$.root.offsetHeight)) {
|
|
662
|
+
_resizeLock.resolve();
|
|
663
|
+
}
|
|
664
|
+
return lock;
|
|
665
|
+
}).then(function(){
|
|
666
|
+
return this$._resize = function(){};
|
|
667
|
+
}).then(function(){
|
|
668
|
+
var init, layoutLock;
|
|
669
|
+
init = function(){
|
|
670
|
+
if (this$.mod.init) {
|
|
671
|
+
return this$.mod.init.apply(this$);
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
if (!this$.layout) {
|
|
675
|
+
return init();
|
|
676
|
+
}
|
|
677
|
+
layoutLock = proxise(function(){
|
|
678
|
+
Promise.resolve(this$.layout.init(init));
|
|
679
|
+
return null;
|
|
680
|
+
});
|
|
681
|
+
this$._layout = function(){
|
|
682
|
+
return layoutLock.resolve();
|
|
683
|
+
};
|
|
684
|
+
this$.layout.on('render', function(){
|
|
685
|
+
return this$._layout();
|
|
686
|
+
});
|
|
687
|
+
return layoutLock();
|
|
688
|
+
}).then(function(){
|
|
689
|
+
this$._layout = function(){};
|
|
690
|
+
Promise.resolve().then(function(){
|
|
691
|
+
if (!this$.delayRender || this$._pendingRaw) {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
this$.renderLock = proxise(function(){});
|
|
695
|
+
return this$.renderLock();
|
|
696
|
+
}).then(function(){
|
|
697
|
+
this$._inited = true;
|
|
698
|
+
this$._resize = function(){
|
|
699
|
+
this$.resize();
|
|
700
|
+
return this$.render();
|
|
701
|
+
};
|
|
702
|
+
this$._layout = function(){
|
|
703
|
+
this$.parse();
|
|
704
|
+
this$.bind();
|
|
705
|
+
this$.resize();
|
|
706
|
+
return this$.render();
|
|
707
|
+
};
|
|
708
|
+
this$.parse();
|
|
709
|
+
this$.bind();
|
|
710
|
+
this$.resize();
|
|
711
|
+
return this$.render();
|
|
712
|
+
});
|
|
713
|
+
});
|
|
714
|
+
},
|
|
715
|
+
parse: function(){
|
|
716
|
+
var dim, ref$, bind;
|
|
717
|
+
dim = (ref$ = this.mod).dimension || (ref$.dimension = {});
|
|
718
|
+
bind = this.binding;
|
|
719
|
+
this.data = this.raw.map(function(r, i){
|
|
720
|
+
var ret, k, ref$, v, b;
|
|
721
|
+
ret = {};
|
|
722
|
+
for (k in ref$ = dim) {
|
|
723
|
+
v = ref$[k];
|
|
724
|
+
if (!(b = bind[k])) {
|
|
725
|
+
if (v.multiple) {
|
|
726
|
+
ret[k] = [];
|
|
727
|
+
}
|
|
728
|
+
continue;
|
|
729
|
+
}
|
|
730
|
+
ret[k] = !v.multiple
|
|
731
|
+
? r[b.key]
|
|
732
|
+
: (b.map
|
|
733
|
+
? b
|
|
734
|
+
: [b]).map(fn$);
|
|
735
|
+
if (/[RIT]/.exec(v.type) && !/[CN]/.exec(v.type)) {
|
|
736
|
+
ret[k] = Array.isArray(ret[k])
|
|
737
|
+
? ret[k].map(fn1$)
|
|
738
|
+
: _nparse(ret[k]);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
ret._raw = r;
|
|
742
|
+
ret._idx = i;
|
|
743
|
+
return ret;
|
|
744
|
+
function fn$(it){
|
|
745
|
+
return r[it.key];
|
|
746
|
+
}
|
|
747
|
+
function fn1$(it){
|
|
748
|
+
return _nparse(it);
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
_parseSubset.apply(this);
|
|
752
|
+
if (this.mod.parse) {
|
|
753
|
+
return this.mod.parse.apply(this);
|
|
754
|
+
}
|
|
755
|
+
},
|
|
756
|
+
bind: function(){
|
|
757
|
+
if (this.mod.bind) {
|
|
758
|
+
return this.mod.bind.apply(this);
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
start: function(){
|
|
762
|
+
this._aniloop.run();
|
|
763
|
+
if (this.mod.start) {
|
|
764
|
+
return this.mod.start.apply(this);
|
|
765
|
+
}
|
|
766
|
+
},
|
|
767
|
+
stop: function(){
|
|
768
|
+
this._aniloop.pause();
|
|
769
|
+
if (this.mod.stop) {
|
|
770
|
+
return this.mod.stop.apply(this);
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
resize: function(){
|
|
774
|
+
if (!this._inited) {
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
if (this.layout) {
|
|
778
|
+
this.layout.update(false);
|
|
779
|
+
}
|
|
780
|
+
this.box = this.root.getBoundingClientRect();
|
|
781
|
+
if (this.mod.resize) {
|
|
782
|
+
return this.mod.resize.apply(this);
|
|
783
|
+
}
|
|
784
|
+
},
|
|
785
|
+
tick: function(t, dt){
|
|
786
|
+
if (this.mod.tick) {
|
|
787
|
+
return this.mod.tick.apply(this, [t, dt]);
|
|
788
|
+
}
|
|
789
|
+
},
|
|
790
|
+
render: function(){
|
|
791
|
+
if (!this._inited) {
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
if (this.mod.render) {
|
|
795
|
+
return this.mod.render.apply(this);
|
|
796
|
+
}
|
|
797
|
+
},
|
|
798
|
+
destroy: function(){
|
|
799
|
+
var this$ = this;
|
|
800
|
+
return Promise.resolve().then(function(){
|
|
801
|
+
if (this$._select) {
|
|
802
|
+
this$.root.removeEventListener('click', this$._select);
|
|
803
|
+
}
|
|
804
|
+
if (this$._hover) {
|
|
805
|
+
this$.root.removeEventListener('mouseover', this$._hover);
|
|
806
|
+
}
|
|
807
|
+
resizeObserver['delete'](this$.root);
|
|
808
|
+
if (this$.layout) {
|
|
809
|
+
this$.layout.destroy();
|
|
810
|
+
}
|
|
811
|
+
this$.stop();
|
|
812
|
+
if (this$.mod.destroy) {
|
|
813
|
+
return this$.mod.destroy.apply(this$);
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
},
|
|
817
|
+
config: function(){
|
|
818
|
+
var args, o, i$, to$, i;
|
|
819
|
+
if (!(args = arguments).length) {
|
|
820
|
+
return this.cfg;
|
|
821
|
+
}
|
|
822
|
+
o = {};
|
|
823
|
+
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
|
|
824
|
+
i = i$;
|
|
825
|
+
withDefault(o, arguments[i], this.mod.config);
|
|
826
|
+
}
|
|
827
|
+
withDefault(o, this.cfg, this.mod.config);
|
|
828
|
+
withDefault(o, this._defcfg, this.mod.config);
|
|
829
|
+
return import$(this.cfg, o);
|
|
830
|
+
},
|
|
831
|
+
_normalizeBinding: function(k){
|
|
832
|
+
var k, res$, i$, len$, n, d, b, a, results$ = [];
|
|
833
|
+
if (k == null) {
|
|
834
|
+
res$ = [];
|
|
835
|
+
for (k in this.mod.dimension || {}) {
|
|
836
|
+
res$.push(k);
|
|
837
|
+
}
|
|
838
|
+
k = res$;
|
|
839
|
+
}
|
|
840
|
+
if (!Array.isArray(k)) {
|
|
841
|
+
k = [k];
|
|
842
|
+
}
|
|
843
|
+
for (i$ = 0, len$ = k.length; i$ < len$; ++i$) {
|
|
844
|
+
n = k[i$];
|
|
845
|
+
d = (this.mod.dimension || {})[n] || {};
|
|
846
|
+
b = this.binding[n];
|
|
847
|
+
a = Array.isArray(b);
|
|
848
|
+
if (!d.multiple !== !a && (d.multiple || a)) {
|
|
849
|
+
results$.push(this.binding[n] = a
|
|
850
|
+
? b[0]
|
|
851
|
+
: b
|
|
852
|
+
? [b]
|
|
853
|
+
: []);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
return results$;
|
|
857
|
+
},
|
|
858
|
+
setBind: function(n, b){
|
|
859
|
+
this.binding[n] = b;
|
|
860
|
+
this._normalizeBinding([n]);
|
|
861
|
+
if (!this._inited) {
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
this.parse();
|
|
865
|
+
this.bind();
|
|
866
|
+
this.resize();
|
|
867
|
+
return this.render();
|
|
868
|
+
},
|
|
869
|
+
setRaw: function(raw, binding, reinit){
|
|
870
|
+
var ref$;
|
|
871
|
+
reinit == null && (reinit = false);
|
|
872
|
+
if (!Array.isArray(raw)) {
|
|
873
|
+
if (raw && 'subset' in raw) {
|
|
874
|
+
this._subset = raw.subset || null;
|
|
875
|
+
}
|
|
876
|
+
ref$ = raw, raw = ref$.raw, binding = ref$.binding, reinit = ref$.reinit;
|
|
877
|
+
}
|
|
878
|
+
if (raw != null) {
|
|
879
|
+
this.raw = raw;
|
|
880
|
+
}
|
|
881
|
+
if (binding != null) {
|
|
882
|
+
this.binding = binding;
|
|
883
|
+
this._normalizeBinding();
|
|
884
|
+
}
|
|
885
|
+
if (this.renderLock) {
|
|
886
|
+
this.renderLock.resolve();
|
|
887
|
+
return this.renderLock = null;
|
|
888
|
+
} else if (!this._inited) {
|
|
889
|
+
return this._pendingRaw = true;
|
|
890
|
+
} else {
|
|
891
|
+
if (reinit && this.mod.init) {
|
|
892
|
+
this.mod.init.apply(this);
|
|
893
|
+
}
|
|
894
|
+
this.parse();
|
|
895
|
+
this.bind();
|
|
896
|
+
this.resize();
|
|
897
|
+
return this.render();
|
|
898
|
+
}
|
|
899
|
+
},
|
|
900
|
+
on: function(n, cb){
|
|
901
|
+
var this$ = this;
|
|
902
|
+
return (Array.isArray(n)
|
|
903
|
+
? n
|
|
904
|
+
: [n]).map(function(n){
|
|
905
|
+
var ref$;
|
|
906
|
+
return ((ref$ = this$.evtHandler)[n] || (ref$[n] = [])).push(cb);
|
|
907
|
+
});
|
|
908
|
+
},
|
|
909
|
+
fire: function(n){
|
|
910
|
+
var v, res$, i$, to$, ref$, len$, cb, results$ = [];
|
|
911
|
+
res$ = [];
|
|
912
|
+
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
|
|
913
|
+
res$.push(arguments[i$]);
|
|
914
|
+
}
|
|
915
|
+
v = res$;
|
|
916
|
+
for (i$ = 0, len$ = (ref$ = this.evtHandler[n] || []).length; i$ < len$; ++i$) {
|
|
917
|
+
cb = ref$[i$];
|
|
918
|
+
results$.push(cb.apply(this, v));
|
|
919
|
+
}
|
|
920
|
+
return results$;
|
|
921
|
+
},
|
|
922
|
+
filter: function(filters, internal){
|
|
923
|
+
var bs, k, ref$, v, u;
|
|
924
|
+
filters == null && (filters = {});
|
|
925
|
+
internal == null && (internal = false);
|
|
926
|
+
bs = [];
|
|
927
|
+
for (k in ref$ = this.binding) {
|
|
928
|
+
v = ref$[k];
|
|
929
|
+
u = Array.isArray(v)
|
|
930
|
+
? v
|
|
931
|
+
: [v];
|
|
932
|
+
u = u.map(fn$);
|
|
933
|
+
bs = bs.concat(u);
|
|
934
|
+
}
|
|
935
|
+
for (k in filters) {
|
|
936
|
+
v = filters[k];
|
|
937
|
+
bs.filter(fn1$).map(fn2$);
|
|
938
|
+
}
|
|
939
|
+
if (internal) {
|
|
940
|
+
this.fire('filter', filters);
|
|
941
|
+
}
|
|
942
|
+
if (this.mod.filter) {
|
|
943
|
+
this.mod.filter.apply(this, [filters, internal]);
|
|
944
|
+
}
|
|
945
|
+
this.parse();
|
|
946
|
+
this.bind();
|
|
947
|
+
this.resize();
|
|
948
|
+
return this.render();
|
|
949
|
+
function fn$(v){
|
|
950
|
+
return {
|
|
951
|
+
k: k,
|
|
952
|
+
v: v
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
function fn1$(it){
|
|
956
|
+
return it.k === k;
|
|
957
|
+
}
|
|
958
|
+
function fn2$(it){
|
|
959
|
+
return it.v.filter = v;
|
|
960
|
+
}
|
|
961
|
+
},
|
|
962
|
+
sample: function(){
|
|
963
|
+
if (this.mod.sample) {
|
|
964
|
+
return this.mod.sample.apply(this);
|
|
965
|
+
} else {
|
|
966
|
+
return {
|
|
967
|
+
raw: [],
|
|
968
|
+
binding: {}
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
filterDims: function(){
|
|
973
|
+
var that;
|
|
974
|
+
if (that = (this.mod || {}).filterDims) {
|
|
975
|
+
return that.call(this);
|
|
976
|
+
} else if ((this.mod || {}).filter) {
|
|
977
|
+
return ['name'];
|
|
978
|
+
} else {
|
|
979
|
+
return [];
|
|
980
|
+
}
|
|
981
|
+
},
|
|
982
|
+
canFilter: function(){
|
|
983
|
+
return !!this.filterDims().length;
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
chart.commonConfig = {
|
|
987
|
+
common: {
|
|
988
|
+
subset: {
|
|
989
|
+
mode: {
|
|
990
|
+
type: 'choice',
|
|
991
|
+
values: ['dim', 'partial', 'shrink'],
|
|
992
|
+
'default': 'dim'
|
|
993
|
+
},
|
|
994
|
+
opacity: {
|
|
995
|
+
type: 'number',
|
|
996
|
+
'default': 0.2,
|
|
997
|
+
min: 0,
|
|
998
|
+
max: 1,
|
|
999
|
+
step: 0.05
|
|
1000
|
+
},
|
|
1001
|
+
fade: {
|
|
1002
|
+
type: 'number',
|
|
1003
|
+
'default': 0.72,
|
|
1004
|
+
min: 0,
|
|
1005
|
+
max: 1,
|
|
1006
|
+
step: 0.01
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
chart.scopes = {
|
|
1012
|
+
subset: {
|
|
1013
|
+
set: function(raw){
|
|
1014
|
+
this._subset = raw || null;
|
|
1015
|
+
if (!this._inited) {
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
this.parse();
|
|
1019
|
+
this.bind();
|
|
1020
|
+
this.resize();
|
|
1021
|
+
return this.render();
|
|
1022
|
+
},
|
|
1023
|
+
mode: function(){
|
|
1024
|
+
return (((this.cfg || {}).common || {}).subset || {}).mode || 'dim';
|
|
1025
|
+
},
|
|
1026
|
+
ratio: function(d, k, i){
|
|
1027
|
+
var ref$, v, p, r;
|
|
1028
|
+
if (!(d && d.subset)) {
|
|
1029
|
+
return null;
|
|
1030
|
+
}
|
|
1031
|
+
ref$ = i != null
|
|
1032
|
+
? [(d[k] || [])[i], (d.subset[k] || [])[i]]
|
|
1033
|
+
: [d[k], d.subset[k]], v = ref$[0], p = ref$[1];
|
|
1034
|
+
if (!v) {
|
|
1035
|
+
return 0;
|
|
1036
|
+
}
|
|
1037
|
+
r = p / v;
|
|
1038
|
+
if (r < 0) {
|
|
1039
|
+
return 0;
|
|
1040
|
+
} else if (r > 1) {
|
|
1041
|
+
return 1;
|
|
1042
|
+
} else {
|
|
1043
|
+
return r;
|
|
1044
|
+
}
|
|
1045
|
+
},
|
|
1046
|
+
color: function(color, fade){
|
|
1047
|
+
var rgb, g, f, v;
|
|
1048
|
+
if (!(rgb = _rgb(color))) {
|
|
1049
|
+
return color;
|
|
1050
|
+
}
|
|
1051
|
+
g = 0.3 * rgb[0] + 0.59 * rgb[1] + 0.11 * rgb[2];
|
|
1052
|
+
f = fade != null
|
|
1053
|
+
? fade
|
|
1054
|
+
: (((this.cfg || {}).common || {}).subset || {}).fade;
|
|
1055
|
+
f = f != null ? f : 0.72;
|
|
1056
|
+
v = Math.round(g + (255 - g) * f);
|
|
1057
|
+
return "rgb(" + v + "," + v + "," + v + ")";
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
if (typeof module != 'undefined' && module !== null) {
|
|
1062
|
+
module.exports = chart;
|
|
1063
|
+
} else if (typeof window != 'undefined' && window !== null) {
|
|
1064
|
+
window.chart = chart;
|
|
1065
|
+
}
|
|
1066
|
+
function deepEq$(x, y, type){
|
|
1067
|
+
var toString = {}.toString, hasOwnProperty = {}.hasOwnProperty,
|
|
1068
|
+
has = function (obj, key) { return hasOwnProperty.call(obj, key); };
|
|
1069
|
+
var first = true;
|
|
1070
|
+
return eq(x, y, []);
|
|
1071
|
+
function eq(a, b, stack) {
|
|
1072
|
+
var className, length, size, result, alength, blength, r, key, ref, sizeB;
|
|
1073
|
+
if (a == null || b == null) { return a === b; }
|
|
1074
|
+
if (a.__placeholder__ || b.__placeholder__) { return true; }
|
|
1075
|
+
if (a === b) { return a !== 0 || 1 / a == 1 / b; }
|
|
1076
|
+
className = toString.call(a);
|
|
1077
|
+
if (toString.call(b) != className) { return false; }
|
|
1078
|
+
switch (className) {
|
|
1079
|
+
case '[object String]': return a == String(b);
|
|
1080
|
+
case '[object Number]':
|
|
1081
|
+
return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
|
|
1082
|
+
case '[object Date]':
|
|
1083
|
+
case '[object Boolean]':
|
|
1084
|
+
return +a == +b;
|
|
1085
|
+
case '[object RegExp]':
|
|
1086
|
+
return a.source == b.source &&
|
|
1087
|
+
a.global == b.global &&
|
|
1088
|
+
a.multiline == b.multiline &&
|
|
1089
|
+
a.ignoreCase == b.ignoreCase;
|
|
1090
|
+
}
|
|
1091
|
+
if (typeof a != 'object' || typeof b != 'object') { return false; }
|
|
1092
|
+
length = stack.length;
|
|
1093
|
+
while (length--) { if (stack[length] == a) { return true; } }
|
|
1094
|
+
stack.push(a);
|
|
1095
|
+
size = 0;
|
|
1096
|
+
result = true;
|
|
1097
|
+
if (className == '[object Array]') {
|
|
1098
|
+
alength = a.length;
|
|
1099
|
+
blength = b.length;
|
|
1100
|
+
if (first) {
|
|
1101
|
+
switch (type) {
|
|
1102
|
+
case '===': result = alength === blength; break;
|
|
1103
|
+
case '<==': result = alength <= blength; break;
|
|
1104
|
+
case '<<=': result = alength < blength; break;
|
|
1105
|
+
}
|
|
1106
|
+
size = alength;
|
|
1107
|
+
first = false;
|
|
1108
|
+
} else {
|
|
1109
|
+
result = alength === blength;
|
|
1110
|
+
size = alength;
|
|
1111
|
+
}
|
|
1112
|
+
if (result) {
|
|
1113
|
+
while (size--) {
|
|
1114
|
+
if (!(result = size in a == size in b && eq(a[size], b[size], stack))){ break; }
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
} else {
|
|
1118
|
+
if ('constructor' in a != 'constructor' in b || a.constructor != b.constructor) {
|
|
1119
|
+
return false;
|
|
1120
|
+
}
|
|
1121
|
+
for (key in a) {
|
|
1122
|
+
if (has(a, key)) {
|
|
1123
|
+
size++;
|
|
1124
|
+
if (!(result = has(b, key) && eq(a[key], b[key], stack))) { break; }
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
if (result) {
|
|
1128
|
+
sizeB = 0;
|
|
1129
|
+
for (key in b) {
|
|
1130
|
+
if (has(b, key)) { ++sizeB; }
|
|
1131
|
+
}
|
|
1132
|
+
if (first) {
|
|
1133
|
+
if (type === '<<=') {
|
|
1134
|
+
result = size < sizeB;
|
|
1135
|
+
} else if (type === '<==') {
|
|
1136
|
+
result = size <= sizeB
|
|
1137
|
+
} else {
|
|
1138
|
+
result = size === sizeB;
|
|
1139
|
+
}
|
|
1140
|
+
} else {
|
|
1141
|
+
first = false;
|
|
1142
|
+
result = size === sizeB;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
stack.pop();
|
|
1147
|
+
return result;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
function import$(obj, src){
|
|
1151
|
+
var own = {}.hasOwnProperty;
|
|
1152
|
+
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
|
1153
|
+
return obj;
|
|
1154
|
+
}
|
|
1155
|
+
}).call(this);
|
|
1156
|
+
var chart = module.exports;
|
|
1157
|
+
(function(){
|
|
1158
|
+
var d3f, format;
|
|
1159
|
+
d3f = {
|
|
1160
|
+
re: /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i,
|
|
1161
|
+
prefixes: ['y', 'z', 'a', 'f', 'p', 'n', 'µ', 'm'].concat([''], ['k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']),
|
|
1162
|
+
locale: {
|
|
1163
|
+
decimal: '.',
|
|
1164
|
+
thousands: ',',
|
|
1165
|
+
grouping: [3],
|
|
1166
|
+
currency: ['$', ''],
|
|
1167
|
+
minus: '−',
|
|
1168
|
+
percent: '%',
|
|
1169
|
+
nan: 'NaN'
|
|
1170
|
+
},
|
|
1171
|
+
parts: function(x, p){
|
|
1172
|
+
var i, c;
|
|
1173
|
+
if (!isFinite(x) || x === 0) {
|
|
1174
|
+
return null;
|
|
1175
|
+
}
|
|
1176
|
+
x = p
|
|
1177
|
+
? x.toExponential(p - 1)
|
|
1178
|
+
: x.toExponential();
|
|
1179
|
+
if ((i = x.indexOf('e')) < 0) {
|
|
1180
|
+
return null;
|
|
1181
|
+
}
|
|
1182
|
+
c = x.slice(0, i);
|
|
1183
|
+
return [c.length > 1 ? c[0] + c.slice(2) : c, +x.slice(i + 1)];
|
|
1184
|
+
},
|
|
1185
|
+
rounded: function(x, p){
|
|
1186
|
+
var d, c, e;
|
|
1187
|
+
if (!(d = d3f.parts(x, p))) {
|
|
1188
|
+
return x + "";
|
|
1189
|
+
}
|
|
1190
|
+
c = d[0], e = d[1];
|
|
1191
|
+
if (e < 0) {
|
|
1192
|
+
return "0." + new Array(-e).join('0') + c;
|
|
1193
|
+
} else if (c.length > e + 1) {
|
|
1194
|
+
return c.slice(0, e + 1) + '.' + c.slice(e + 1);
|
|
1195
|
+
} else {
|
|
1196
|
+
return c + new Array(e - c.length + 2).join('0');
|
|
1197
|
+
}
|
|
1198
|
+
},
|
|
1199
|
+
prefixAuto: function(x, p){
|
|
1200
|
+
var d, c, e, i, n;
|
|
1201
|
+
if (!(d = d3f.parts(x, p))) {
|
|
1202
|
+
d3f._pe = undefined;
|
|
1203
|
+
return x.toPrecision(p);
|
|
1204
|
+
}
|
|
1205
|
+
c = d[0], e = d[1];
|
|
1206
|
+
d3f._pe = Math.max(-8, Math.min(8, Math.floor(e / 3))) * 3;
|
|
1207
|
+
i = e - d3f._pe + 1;
|
|
1208
|
+
n = c.length;
|
|
1209
|
+
if (i === n) {
|
|
1210
|
+
return c;
|
|
1211
|
+
} else if (i > n) {
|
|
1212
|
+
return c + new Array(i - n + 1).join('0');
|
|
1213
|
+
} else if (i > 0) {
|
|
1214
|
+
return c.slice(0, i) + '.' + c.slice(i);
|
|
1215
|
+
} else {
|
|
1216
|
+
return "0." + new Array(1 - i).join('0') + d3f.parts(x, Math.max(0, p + i - 1))[0];
|
|
1217
|
+
}
|
|
1218
|
+
},
|
|
1219
|
+
decimal: function(x){
|
|
1220
|
+
if (Math.abs(x = Math.round(x)) >= 1e21) {
|
|
1221
|
+
return x.toLocaleString('en').replace(/,/g, '');
|
|
1222
|
+
} else {
|
|
1223
|
+
return x.toString(10);
|
|
1224
|
+
}
|
|
1225
|
+
},
|
|
1226
|
+
types: {
|
|
1227
|
+
"%": function(x, p){
|
|
1228
|
+
return (x * 100).toFixed(p);
|
|
1229
|
+
},
|
|
1230
|
+
b: function(x){
|
|
1231
|
+
return Math.round(x).toString(2);
|
|
1232
|
+
},
|
|
1233
|
+
c: function(x){
|
|
1234
|
+
return x + "";
|
|
1235
|
+
},
|
|
1236
|
+
d: function(x){
|
|
1237
|
+
return d3f.decimal(x);
|
|
1238
|
+
},
|
|
1239
|
+
e: function(x, p){
|
|
1240
|
+
return x.toExponential(p);
|
|
1241
|
+
},
|
|
1242
|
+
f: function(x, p){
|
|
1243
|
+
return x.toFixed(p);
|
|
1244
|
+
},
|
|
1245
|
+
g: function(x, p){
|
|
1246
|
+
return x.toPrecision(p);
|
|
1247
|
+
},
|
|
1248
|
+
o: function(x){
|
|
1249
|
+
return Math.round(x).toString(8);
|
|
1250
|
+
},
|
|
1251
|
+
p: function(x, p){
|
|
1252
|
+
return d3f.rounded(x * 100, p);
|
|
1253
|
+
},
|
|
1254
|
+
r: function(x, p){
|
|
1255
|
+
return d3f.rounded(x, p);
|
|
1256
|
+
},
|
|
1257
|
+
s: function(x, p){
|
|
1258
|
+
return d3f.prefixAuto(x, p);
|
|
1259
|
+
},
|
|
1260
|
+
X: function(x){
|
|
1261
|
+
return Math.round(x).toString(16).toUpperCase();
|
|
1262
|
+
},
|
|
1263
|
+
x: function(x){
|
|
1264
|
+
return Math.round(x).toString(16);
|
|
1265
|
+
}
|
|
1266
|
+
},
|
|
1267
|
+
trim: function(s){
|
|
1268
|
+
var ref$, i0, i1, i$, to$, i, c;
|
|
1269
|
+
ref$ = [-1, -1], i0 = ref$[0], i1 = ref$[1];
|
|
1270
|
+
for (i$ = 1, to$ = s.length; i$ < to$; ++i$) {
|
|
1271
|
+
i = i$;
|
|
1272
|
+
c = s[i];
|
|
1273
|
+
if (c === '.') {
|
|
1274
|
+
i0 = i1 = i;
|
|
1275
|
+
} else if (c === '0') {
|
|
1276
|
+
if (i0 === 0) {
|
|
1277
|
+
i0 = i;
|
|
1278
|
+
}
|
|
1279
|
+
i1 = i;
|
|
1280
|
+
} else {
|
|
1281
|
+
if (!+c) {
|
|
1282
|
+
break;
|
|
1283
|
+
}
|
|
1284
|
+
if (i0 > 0) {
|
|
1285
|
+
i0 = 0;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
if (i0 > 0) {
|
|
1290
|
+
return s.slice(0, i0) + s.slice(i1 + 1);
|
|
1291
|
+
} else {
|
|
1292
|
+
return s;
|
|
1293
|
+
}
|
|
1294
|
+
},
|
|
1295
|
+
group: function(value, width){
|
|
1296
|
+
var ref$, grouping, thousands, i, t, j, g, len;
|
|
1297
|
+
ref$ = d3f.locale, grouping = ref$.grouping, thousands = ref$.thousands;
|
|
1298
|
+
ref$ = [value.length, [], 0, grouping[0], 0], i = ref$[0], t = ref$[1], j = ref$[2], g = ref$[3], len = ref$[4];
|
|
1299
|
+
while (i > 0 && g > 0) {
|
|
1300
|
+
if (len + g + 1 > width) {
|
|
1301
|
+
g = Math.max(1, width - len);
|
|
1302
|
+
}
|
|
1303
|
+
t.push(value.substring(i -= g, i + g));
|
|
1304
|
+
if ((len += g + 1) > width) {
|
|
1305
|
+
break;
|
|
1306
|
+
}
|
|
1307
|
+
g = grouping[j = (j + 1) % grouping.length];
|
|
1308
|
+
}
|
|
1309
|
+
return t.reverse().join(thousands);
|
|
1310
|
+
},
|
|
1311
|
+
format: function(spec){
|
|
1312
|
+
var m, L, fill, align, sign, symbol, zero, width, comma, precision, trim, type, ref$, prefix, suffix, ft, maybeSuffix;
|
|
1313
|
+
if (!(m = d3f.re.exec(spec))) {
|
|
1314
|
+
throw new Error("invalid format: " + spec);
|
|
1315
|
+
}
|
|
1316
|
+
L = d3f.locale;
|
|
1317
|
+
fill = m[1] != null ? m[1] : ' ';
|
|
1318
|
+
align = m[2] || '>';
|
|
1319
|
+
sign = m[3] || '-';
|
|
1320
|
+
symbol = m[4] || '';
|
|
1321
|
+
zero = !!m[5];
|
|
1322
|
+
width = m[6] != null ? +m[6] : undefined;
|
|
1323
|
+
comma = !!m[7];
|
|
1324
|
+
precision = m[8] ? +m[8].slice(1) : undefined;
|
|
1325
|
+
trim = !!m[9];
|
|
1326
|
+
type = m[10] || '';
|
|
1327
|
+
if (type === 'n') {
|
|
1328
|
+
ref$ = [true, 'g'], comma = ref$[0], type = ref$[1];
|
|
1329
|
+
} else if (!d3f.types[type]) {
|
|
1330
|
+
if (!(precision != null)) {
|
|
1331
|
+
precision = 12;
|
|
1332
|
+
}
|
|
1333
|
+
ref$ = [true, 'g'], trim = ref$[0], type = ref$[1];
|
|
1334
|
+
}
|
|
1335
|
+
if (zero || (fill === '0' && align === '=')) {
|
|
1336
|
+
ref$ = [true, '0', '='], zero = ref$[0], fill = ref$[1], align = ref$[2];
|
|
1337
|
+
}
|
|
1338
|
+
prefix = symbol === '$'
|
|
1339
|
+
? L.currency[0]
|
|
1340
|
+
: symbol === '#' && /[boxX]/.test(type) ? '0' + type.toLowerCase() : '';
|
|
1341
|
+
suffix = symbol === '$'
|
|
1342
|
+
? L.currency[1]
|
|
1343
|
+
: /[%p]/.test(type) ? L.percent : '';
|
|
1344
|
+
ft = d3f.types[type];
|
|
1345
|
+
maybeSuffix = /[defgprs%]/.test(type);
|
|
1346
|
+
precision = !(precision != null)
|
|
1347
|
+
? 6
|
|
1348
|
+
: /[gprs]/.test(type)
|
|
1349
|
+
? Math.max(1, Math.min(21, precision))
|
|
1350
|
+
: Math.max(0, Math.min(20, precision));
|
|
1351
|
+
return function(value){
|
|
1352
|
+
var ref$, vp, vs, neg, i$, to$, i, c, len, padding, h;
|
|
1353
|
+
ref$ = [prefix, suffix], vp = ref$[0], vs = ref$[1];
|
|
1354
|
+
if (type === 'c') {
|
|
1355
|
+
vs = ft(value) + vs;
|
|
1356
|
+
value = '';
|
|
1357
|
+
} else {
|
|
1358
|
+
value = +value;
|
|
1359
|
+
neg = value < 0 || 1 / value < 0;
|
|
1360
|
+
value = isNaN(value)
|
|
1361
|
+
? L.nan
|
|
1362
|
+
: ft(Math.abs(value), precision);
|
|
1363
|
+
if (trim) {
|
|
1364
|
+
value = d3f.trim(value);
|
|
1365
|
+
}
|
|
1366
|
+
if (neg && +value === 0 && sign !== '+') {
|
|
1367
|
+
neg = false;
|
|
1368
|
+
}
|
|
1369
|
+
vp = (neg
|
|
1370
|
+
? sign === '('
|
|
1371
|
+
? sign
|
|
1372
|
+
: L.minus
|
|
1373
|
+
: sign === '-' || sign === '(' ? '' : sign) + vp;
|
|
1374
|
+
vs = (type === 's' && !isNaN(value) && d3f._pe != null ? d3f.prefixes[8 + d3f._pe / 3] : '') + vs + (neg && sign === '(' ? ')' : '');
|
|
1375
|
+
if (maybeSuffix) {
|
|
1376
|
+
for (i$ = 0, to$ = value.length; i$ < to$; ++i$) {
|
|
1377
|
+
i = i$;
|
|
1378
|
+
c = value.charCodeAt(i);
|
|
1379
|
+
if (48 > c || c > 57) {
|
|
1380
|
+
vs = (c === 46
|
|
1381
|
+
? L.decimal + value.slice(i + 1)
|
|
1382
|
+
: value.slice(i)) + vs;
|
|
1383
|
+
value = value.slice(0, i);
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
if (comma && !zero) {
|
|
1390
|
+
value = d3f.group(value, Infinity);
|
|
1391
|
+
}
|
|
1392
|
+
len = vp.length + value.length + vs.length;
|
|
1393
|
+
padding = len < width ? new Array(width - len + 1).join(fill) : '';
|
|
1394
|
+
if (comma && zero) {
|
|
1395
|
+
value = d3f.group(padding + value, padding.length ? width - vs.length : Infinity);
|
|
1396
|
+
padding = '';
|
|
1397
|
+
}
|
|
1398
|
+
switch (align) {
|
|
1399
|
+
case '<':
|
|
1400
|
+
return vp + value + vs + padding;
|
|
1401
|
+
case '=':
|
|
1402
|
+
return vp + padding + value + vs;
|
|
1403
|
+
case '^':
|
|
1404
|
+
h = padding.length >> 1;
|
|
1405
|
+
return padding.slice(0, h) + vp + value + vs + padding.slice(h);
|
|
1406
|
+
default:
|
|
1407
|
+
return padding + vp + value + vs;
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
format = {
|
|
1413
|
+
d3: function(s){
|
|
1414
|
+
if ((typeof d3 != 'undefined' && d3 !== null) && d3.format) {
|
|
1415
|
+
return d3.format(s);
|
|
1416
|
+
} else {
|
|
1417
|
+
return d3f.format(s);
|
|
1418
|
+
}
|
|
1419
|
+
},
|
|
1420
|
+
from: function(s){
|
|
1421
|
+
var e;
|
|
1422
|
+
try {
|
|
1423
|
+
return format.d3(s);
|
|
1424
|
+
} catch (e$) {
|
|
1425
|
+
e = e$;
|
|
1426
|
+
return function(it){
|
|
1427
|
+
return it;
|
|
1428
|
+
};
|
|
1429
|
+
}
|
|
1430
|
+
},
|
|
1431
|
+
auto: function(list){
|
|
1432
|
+
var s, intRate, diffs, i, diffAvg, type, size;
|
|
1433
|
+
list == null && (list = []);
|
|
1434
|
+
return format.d3(".3s");
|
|
1435
|
+
list = list.map(function(it){
|
|
1436
|
+
return +it;
|
|
1437
|
+
}).filter(function(it){
|
|
1438
|
+
return !isNaN(it);
|
|
1439
|
+
});
|
|
1440
|
+
if (!list.length) {
|
|
1441
|
+
return format.d3("d");
|
|
1442
|
+
}
|
|
1443
|
+
list.sort(function(a, b){
|
|
1444
|
+
return a - b;
|
|
1445
|
+
});
|
|
1446
|
+
s = Math.max.apply(Math, list.map(function(it){
|
|
1447
|
+
var s, ref$;
|
|
1448
|
+
s = 1;
|
|
1449
|
+
while (it) {
|
|
1450
|
+
if (it % 10) {
|
|
1451
|
+
break;
|
|
1452
|
+
}
|
|
1453
|
+
it = Math.floor(it / 10);
|
|
1454
|
+
s++;
|
|
1455
|
+
}
|
|
1456
|
+
return (ref$ = Math.ceil(Math.log(it || 1) / Math.log(10) - s)) > 0 ? ref$ : 0;
|
|
1457
|
+
}));
|
|
1458
|
+
intRate = list.filter(function(it){
|
|
1459
|
+
return Math.floor(it) === it;
|
|
1460
|
+
}).length / list.length;
|
|
1461
|
+
diffs = (function(){
|
|
1462
|
+
var i$, to$, results$ = [];
|
|
1463
|
+
for (i$ = 1, to$ = list.length; i$ < to$; ++i$) {
|
|
1464
|
+
i = i$;
|
|
1465
|
+
results$.push(Math.abs(list[i] - list[i - 1]));
|
|
1466
|
+
}
|
|
1467
|
+
return results$;
|
|
1468
|
+
}()).map(function(it){
|
|
1469
|
+
return Math.log(it ? it : 1) / Math.log(10);
|
|
1470
|
+
});
|
|
1471
|
+
diffAvg = diffs.reduce(function(a, b){
|
|
1472
|
+
return a + b;
|
|
1473
|
+
}, 0) / list.length;
|
|
1474
|
+
type = intRate > 0.9 ? "s" : "f";
|
|
1475
|
+
size = diffAvg >= 0
|
|
1476
|
+
? s > 0 ? s : 0
|
|
1477
|
+
: Math.ceil(Math.abs(diffAvg));
|
|
1478
|
+
return format.d3("." + size + type);
|
|
1479
|
+
},
|
|
1480
|
+
simple: function(v){
|
|
1481
|
+
if (isNaN(v = +v)) {
|
|
1482
|
+
return v;
|
|
1483
|
+
}
|
|
1484
|
+
return v >= 1000000000
|
|
1485
|
+
? (v / 1000000000).toFixed(0) + "G"
|
|
1486
|
+
: v >= 1000000
|
|
1487
|
+
? (v / 1000000).toFixed(0) + "M"
|
|
1488
|
+
: v >= 1000
|
|
1489
|
+
? (v / 1000).toFixed(0) + "K"
|
|
1490
|
+
: Math.floor(v) === v
|
|
1491
|
+
? v.toFixed(0)
|
|
1492
|
+
: v.toFixed(2);
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
format._d3f = d3f;
|
|
1496
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
1497
|
+
(chart.utils || (chart.utils = {})).format = format;
|
|
1498
|
+
}
|
|
1499
|
+
}).call(this);
|
|
1500
|
+
(function(){
|
|
1501
|
+
var e10, e5, e2, tickSpec, ticks, linear, band, scale;
|
|
1502
|
+
e10 = Math.sqrt(50);
|
|
1503
|
+
e5 = Math.sqrt(10);
|
|
1504
|
+
e2 = Math.sqrt(2);
|
|
1505
|
+
tickSpec = function(start, stop, count){
|
|
1506
|
+
var step, power, error, factor, inc, i1, i2;
|
|
1507
|
+
step = (stop - start) / Math.max(0, count);
|
|
1508
|
+
power = Math.floor(Math.log10(step));
|
|
1509
|
+
error = step / Math.pow(10, power);
|
|
1510
|
+
factor = error >= e10
|
|
1511
|
+
? 10
|
|
1512
|
+
: error >= e5
|
|
1513
|
+
? 5
|
|
1514
|
+
: error >= e2 ? 2 : 1;
|
|
1515
|
+
if (power < 0) {
|
|
1516
|
+
inc = Math.pow(10, -power) / factor;
|
|
1517
|
+
i1 = Math.round(start * inc);
|
|
1518
|
+
i2 = Math.round(stop * inc);
|
|
1519
|
+
if (i1 / inc < start) {
|
|
1520
|
+
i1++;
|
|
1521
|
+
}
|
|
1522
|
+
if (i2 / inc > stop) {
|
|
1523
|
+
i2--;
|
|
1524
|
+
}
|
|
1525
|
+
inc = -inc;
|
|
1526
|
+
} else {
|
|
1527
|
+
inc = Math.pow(10, power) * factor;
|
|
1528
|
+
i1 = Math.round(start / inc);
|
|
1529
|
+
i2 = Math.round(stop / inc);
|
|
1530
|
+
if (i1 * inc < start) {
|
|
1531
|
+
i1++;
|
|
1532
|
+
}
|
|
1533
|
+
if (i2 * inc > stop) {
|
|
1534
|
+
i2--;
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
if (i2 < i1 && 0.5 <= count && count < 2) {
|
|
1538
|
+
return tickSpec(start, stop, count * 2);
|
|
1539
|
+
}
|
|
1540
|
+
return [i1, i2, inc];
|
|
1541
|
+
};
|
|
1542
|
+
ticks = function(start, stop, count){
|
|
1543
|
+
var ref$, reverse, i1, i2, inc, n, i$, i, k, results$ = [];
|
|
1544
|
+
ref$ = [+start, +stop, +count], start = ref$[0], stop = ref$[1], count = ref$[2];
|
|
1545
|
+
if (!(count > 0)) {
|
|
1546
|
+
return [];
|
|
1547
|
+
}
|
|
1548
|
+
if (start === stop) {
|
|
1549
|
+
return [start];
|
|
1550
|
+
}
|
|
1551
|
+
reverse = stop < start;
|
|
1552
|
+
ref$ = reverse
|
|
1553
|
+
? tickSpec(stop, start, count)
|
|
1554
|
+
: tickSpec(start, stop, count), i1 = ref$[0], i2 = ref$[1], inc = ref$[2];
|
|
1555
|
+
if (!(i2 >= i1)) {
|
|
1556
|
+
return [];
|
|
1557
|
+
}
|
|
1558
|
+
n = i2 - i1 + 1;
|
|
1559
|
+
for (i$ = 0; i$ < n; ++i$) {
|
|
1560
|
+
i = i$;
|
|
1561
|
+
k = reverse
|
|
1562
|
+
? i2 - i
|
|
1563
|
+
: i1 + i;
|
|
1564
|
+
if (inc < 0) {
|
|
1565
|
+
results$.push(k / -inc);
|
|
1566
|
+
} else {
|
|
1567
|
+
results$.push(k * inc);
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
return results$;
|
|
1571
|
+
};
|
|
1572
|
+
linear = function(){
|
|
1573
|
+
var ref$, d, r, s;
|
|
1574
|
+
ref$ = [[0, 1], [0, 1]], d = ref$[0], r = ref$[1];
|
|
1575
|
+
s = function(x){
|
|
1576
|
+
var d0, d1, r0, r1, ref$, t, b;
|
|
1577
|
+
if (!(x != null) || isNaN(x = +x)) {
|
|
1578
|
+
return undefined;
|
|
1579
|
+
}
|
|
1580
|
+
d0 = d[0], d1 = d[1];
|
|
1581
|
+
r0 = r[0], r1 = r[1];
|
|
1582
|
+
if (d1 < d0) {
|
|
1583
|
+
ref$ = [d1, d0, r1, r0], d0 = ref$[0], d1 = ref$[1], r0 = ref$[2], r1 = ref$[3];
|
|
1584
|
+
}
|
|
1585
|
+
t = (b = d1 - d0)
|
|
1586
|
+
? (x - d0) / b
|
|
1587
|
+
: isNaN(b) ? NaN : 0.5;
|
|
1588
|
+
return r0 * (1 - t) + r1 * t;
|
|
1589
|
+
};
|
|
1590
|
+
s.domain = function(it){
|
|
1591
|
+
if (!arguments.length) {
|
|
1592
|
+
return d.slice();
|
|
1593
|
+
}
|
|
1594
|
+
d = Array.from(it, function(v){
|
|
1595
|
+
return +v;
|
|
1596
|
+
});
|
|
1597
|
+
return s;
|
|
1598
|
+
};
|
|
1599
|
+
s.range = function(it){
|
|
1600
|
+
if (!arguments.length) {
|
|
1601
|
+
return r.slice();
|
|
1602
|
+
}
|
|
1603
|
+
r = Array.from(it, function(v){
|
|
1604
|
+
return +v;
|
|
1605
|
+
});
|
|
1606
|
+
return s;
|
|
1607
|
+
};
|
|
1608
|
+
s.invert = function(y){
|
|
1609
|
+
var d0, d1, r0, r1, t, b;
|
|
1610
|
+
d0 = d[0], d1 = d[1];
|
|
1611
|
+
r0 = r[0], r1 = r[1];
|
|
1612
|
+
t = (b = r1 - r0) ? (y - r0) / b : 0.5;
|
|
1613
|
+
return d0 * (1 - t) + d1 * t;
|
|
1614
|
+
};
|
|
1615
|
+
s.ticks = function(count){
|
|
1616
|
+
count == null && (count = 10);
|
|
1617
|
+
return ticks(d[0], d[d.length - 1], count);
|
|
1618
|
+
};
|
|
1619
|
+
s.copy = function(){
|
|
1620
|
+
return linear().domain(d).range(r);
|
|
1621
|
+
};
|
|
1622
|
+
return s;
|
|
1623
|
+
};
|
|
1624
|
+
band = function(){
|
|
1625
|
+
var ref$, dm, idx, r, pi, po, al, step, bw, vals, rescale, s;
|
|
1626
|
+
ref$ = [[], new Map(), [0, 1], 0, 0, 0.5], dm = ref$[0], idx = ref$[1], r = ref$[2], pi = ref$[3], po = ref$[4], al = ref$[5];
|
|
1627
|
+
ref$ = [0, 0, []], step = ref$[0], bw = ref$[1], vals = ref$[2];
|
|
1628
|
+
rescale = function(){
|
|
1629
|
+
var n, r0, r1, reverse, ref$, start, stop, res$, i$, i;
|
|
1630
|
+
n = dm.length;
|
|
1631
|
+
r0 = r[0], r1 = r[1];
|
|
1632
|
+
reverse = r1 < r0;
|
|
1633
|
+
ref$ = reverse
|
|
1634
|
+
? [r1, r0]
|
|
1635
|
+
: [r0, r1], start = ref$[0], stop = ref$[1];
|
|
1636
|
+
step = (stop - start) / Math.max(1, n - pi + po * 2);
|
|
1637
|
+
start = start + (stop - start - step * (n - pi)) * al;
|
|
1638
|
+
bw = step * (1 - pi);
|
|
1639
|
+
res$ = [];
|
|
1640
|
+
for (i$ = 0; i$ < n; ++i$) {
|
|
1641
|
+
i = i$;
|
|
1642
|
+
res$.push(start + step * i);
|
|
1643
|
+
}
|
|
1644
|
+
vals = res$;
|
|
1645
|
+
if (reverse) {
|
|
1646
|
+
vals.reverse();
|
|
1647
|
+
}
|
|
1648
|
+
return s;
|
|
1649
|
+
};
|
|
1650
|
+
s = function(x){
|
|
1651
|
+
if (idx.has(x)) {
|
|
1652
|
+
return vals[idx.get(x)];
|
|
1653
|
+
} else {
|
|
1654
|
+
return undefined;
|
|
1655
|
+
}
|
|
1656
|
+
};
|
|
1657
|
+
s.domain = function(it){
|
|
1658
|
+
var ref$, i$, len$, v;
|
|
1659
|
+
if (!arguments.length) {
|
|
1660
|
+
return dm.slice();
|
|
1661
|
+
}
|
|
1662
|
+
ref$ = [[], new Map()], dm = ref$[0], idx = ref$[1];
|
|
1663
|
+
for (i$ = 0, len$ = it.length; i$ < len$; ++i$) {
|
|
1664
|
+
v = it[i$];
|
|
1665
|
+
if (!idx.has(v)) {
|
|
1666
|
+
idx.set(v, dm.push(v) - 1);
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
return rescale();
|
|
1670
|
+
};
|
|
1671
|
+
s.range = function(it){
|
|
1672
|
+
if (!arguments.length) {
|
|
1673
|
+
return r.slice();
|
|
1674
|
+
}
|
|
1675
|
+
r = Array.from(it, function(v){
|
|
1676
|
+
return +v;
|
|
1677
|
+
});
|
|
1678
|
+
return rescale();
|
|
1679
|
+
};
|
|
1680
|
+
s.bandwidth = function(){
|
|
1681
|
+
return bw;
|
|
1682
|
+
};
|
|
1683
|
+
s.step = function(){
|
|
1684
|
+
return step;
|
|
1685
|
+
};
|
|
1686
|
+
s.paddingInner = function(it){
|
|
1687
|
+
if (!arguments.length) {
|
|
1688
|
+
return pi;
|
|
1689
|
+
}
|
|
1690
|
+
pi = Math.min(1, it);
|
|
1691
|
+
return rescale();
|
|
1692
|
+
};
|
|
1693
|
+
s.paddingOuter = function(it){
|
|
1694
|
+
if (!arguments.length) {
|
|
1695
|
+
return po;
|
|
1696
|
+
}
|
|
1697
|
+
po = it;
|
|
1698
|
+
return rescale();
|
|
1699
|
+
};
|
|
1700
|
+
s.padding = function(it){
|
|
1701
|
+
if (!arguments.length) {
|
|
1702
|
+
return pi;
|
|
1703
|
+
}
|
|
1704
|
+
pi = Math.min(1, po = it);
|
|
1705
|
+
return rescale();
|
|
1706
|
+
};
|
|
1707
|
+
s.align = function(it){
|
|
1708
|
+
if (!arguments.length) {
|
|
1709
|
+
return al;
|
|
1710
|
+
}
|
|
1711
|
+
al = Math.max(0, Math.min(1, it));
|
|
1712
|
+
return rescale();
|
|
1713
|
+
};
|
|
1714
|
+
s.copy = function(){
|
|
1715
|
+
return band().domain(dm).range(r).paddingInner(pi).paddingOuter(po).align(al);
|
|
1716
|
+
};
|
|
1717
|
+
return rescale();
|
|
1718
|
+
};
|
|
1719
|
+
scale = {
|
|
1720
|
+
linear: linear,
|
|
1721
|
+
band: band,
|
|
1722
|
+
ticks: ticks
|
|
1723
|
+
};
|
|
1724
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
1725
|
+
(chart.utils || (chart.utils = {})).scale = scale;
|
|
1726
|
+
}
|
|
1727
|
+
}).call(this);
|
|
1728
|
+
(function(){
|
|
1729
|
+
var svgns, now, ease, reNum, color, interpColor, interpString, interpolate, anim, join;
|
|
1730
|
+
svgns = "http://www.w3.org/2000/svg";
|
|
1731
|
+
now = function(){
|
|
1732
|
+
if (typeof performance != 'undefined' && performance !== null) {
|
|
1733
|
+
return performance.now();
|
|
1734
|
+
} else {
|
|
1735
|
+
return Date.now();
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
ease = {
|
|
1739
|
+
linear: function(t){
|
|
1740
|
+
return t;
|
|
1741
|
+
},
|
|
1742
|
+
cubicInOut: function(t){
|
|
1743
|
+
t = t * 2;
|
|
1744
|
+
if (t <= 1) {
|
|
1745
|
+
return t * t * t / 2;
|
|
1746
|
+
} else {
|
|
1747
|
+
return ((t -= 2) * t * t + 2) / 2;
|
|
1748
|
+
}
|
|
1749
|
+
},
|
|
1750
|
+
cubicOut: function(t){
|
|
1751
|
+
return --t * t * t + 1;
|
|
1752
|
+
},
|
|
1753
|
+
quadInOut: function(t){
|
|
1754
|
+
t = t * 2;
|
|
1755
|
+
if (t <= 1) {
|
|
1756
|
+
return t * t / 2;
|
|
1757
|
+
} else {
|
|
1758
|
+
return (--t * (2 - t) + 1) / 2;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
};
|
|
1762
|
+
reNum = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
|
|
1763
|
+
color = function(c){
|
|
1764
|
+
var m, v;
|
|
1765
|
+
if (typeof c !== 'string') {
|
|
1766
|
+
return null;
|
|
1767
|
+
}
|
|
1768
|
+
c = c.trim();
|
|
1769
|
+
if (m = /^#([0-9a-f]{3,4})$/i.exec(c)) {
|
|
1770
|
+
v = m[1].split('').map(function(it){
|
|
1771
|
+
return parseInt(it + it, 16);
|
|
1772
|
+
});
|
|
1773
|
+
return [v[0], v[1], v[2], v[3] != null ? v[3] / 255 : 1];
|
|
1774
|
+
}
|
|
1775
|
+
if (m = /^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(c)) {
|
|
1776
|
+
v = [0, 1, 2].map(function(i){
|
|
1777
|
+
return parseInt(m[1].substr(i * 2, 2), 16);
|
|
1778
|
+
});
|
|
1779
|
+
return v.concat([m[2] ? parseInt(m[2], 16) / 255 : 1]);
|
|
1780
|
+
}
|
|
1781
|
+
if (m = /^rgba?\(([^)]+)\)$/i.exec(c)) {
|
|
1782
|
+
v = m[1].split(/[\s,\/]+/).filter(function(it){
|
|
1783
|
+
return it;
|
|
1784
|
+
}).map(function(it){
|
|
1785
|
+
return parseFloat(it);
|
|
1786
|
+
});
|
|
1787
|
+
if (v.length < 3 || v.slice(0, 3).some(function(it){
|
|
1788
|
+
return isNaN(it);
|
|
1789
|
+
})) {
|
|
1790
|
+
return null;
|
|
1791
|
+
}
|
|
1792
|
+
return [v[0], v[1], v[2], v[3] != null && !isNaN(v[3]) ? v[3] : 1];
|
|
1793
|
+
}
|
|
1794
|
+
return null;
|
|
1795
|
+
};
|
|
1796
|
+
interpColor = function(a, b){
|
|
1797
|
+
return function(t){
|
|
1798
|
+
var ref$, r, g, bl, al;
|
|
1799
|
+
ref$ = [0, 1, 2, 3].map(function(i){
|
|
1800
|
+
return a[i] + (b[i] - a[i]) * t;
|
|
1801
|
+
}), r = ref$[0], g = ref$[1], bl = ref$[2], al = ref$[3];
|
|
1802
|
+
ref$ = [r, g, bl].map(function(it){
|
|
1803
|
+
var ref$, ref1$;
|
|
1804
|
+
return (ref$ = (ref1$ = Math.round(it)) > 0 ? ref1$ : 0) < 255 ? ref$ : 255;
|
|
1805
|
+
}), r = ref$[0], g = ref$[1], bl = ref$[2];
|
|
1806
|
+
if (al >= 1) {
|
|
1807
|
+
return "rgb(" + r + ", " + g + ", " + bl + ")";
|
|
1808
|
+
} else {
|
|
1809
|
+
return "rgba(" + r + ", " + g + ", " + bl + ", " + al + ")";
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
};
|
|
1813
|
+
interpString = function(a, b){
|
|
1814
|
+
var an, segs, last, i, m, bv, av;
|
|
1815
|
+
a = a + "";
|
|
1816
|
+
b = b + "";
|
|
1817
|
+
an = a.match(reNum) || [];
|
|
1818
|
+
segs = [];
|
|
1819
|
+
last = 0;
|
|
1820
|
+
i = 0;
|
|
1821
|
+
reNum.lastIndex = 0;
|
|
1822
|
+
while (m = reNum.exec(b)) {
|
|
1823
|
+
if (m.index > last) {
|
|
1824
|
+
segs.push(b.slice(last, m.index));
|
|
1825
|
+
}
|
|
1826
|
+
bv = +m[0];
|
|
1827
|
+
av = an[i] != null ? +an[i] : null;
|
|
1828
|
+
segs.push(av != null && av !== bv
|
|
1829
|
+
? {
|
|
1830
|
+
a: av,
|
|
1831
|
+
b: bv
|
|
1832
|
+
}
|
|
1833
|
+
: m[0]);
|
|
1834
|
+
last = reNum.lastIndex;
|
|
1835
|
+
i++;
|
|
1836
|
+
}
|
|
1837
|
+
if (last < b.length) {
|
|
1838
|
+
segs.push(b.slice(last));
|
|
1839
|
+
}
|
|
1840
|
+
if (!segs.some(function(it){
|
|
1841
|
+
return typeof it === 'object';
|
|
1842
|
+
})) {
|
|
1843
|
+
return function(){
|
|
1844
|
+
return b;
|
|
1845
|
+
};
|
|
1846
|
+
}
|
|
1847
|
+
return function(t){
|
|
1848
|
+
return segs.map(function(it){
|
|
1849
|
+
if (typeof it === 'object') {
|
|
1850
|
+
return it.a + (it.b - it.a) * t;
|
|
1851
|
+
} else {
|
|
1852
|
+
return it;
|
|
1853
|
+
}
|
|
1854
|
+
}).join('');
|
|
1855
|
+
};
|
|
1856
|
+
};
|
|
1857
|
+
interpolate = function(a, b){
|
|
1858
|
+
var cb, ca;
|
|
1859
|
+
if (typeof b === 'number') {
|
|
1860
|
+
a = parseFloat(a);
|
|
1861
|
+
if (isNaN(a)) {
|
|
1862
|
+
a = 0;
|
|
1863
|
+
}
|
|
1864
|
+
return function(t){
|
|
1865
|
+
return a + (b - a) * t;
|
|
1866
|
+
};
|
|
1867
|
+
}
|
|
1868
|
+
if (!(a != null)) {
|
|
1869
|
+
return function(){
|
|
1870
|
+
return b;
|
|
1871
|
+
};
|
|
1872
|
+
}
|
|
1873
|
+
if (cb = color(b)) {
|
|
1874
|
+
if (!(ca = color(a))) {
|
|
1875
|
+
return function(){
|
|
1876
|
+
return b;
|
|
1877
|
+
};
|
|
1878
|
+
}
|
|
1879
|
+
return interpColor(ca, cb);
|
|
1880
|
+
}
|
|
1881
|
+
return interpString(a, b);
|
|
1882
|
+
};
|
|
1883
|
+
anim = function(opt){
|
|
1884
|
+
var this$ = this;
|
|
1885
|
+
opt == null && (opt = {});
|
|
1886
|
+
this._manual = !!opt.manual;
|
|
1887
|
+
this._now = 0;
|
|
1888
|
+
this._offset = 0;
|
|
1889
|
+
this._raf = null;
|
|
1890
|
+
this._list = new Map();
|
|
1891
|
+
this.evtHandler = {};
|
|
1892
|
+
this._tick = function(t){
|
|
1893
|
+
this$._raf = null;
|
|
1894
|
+
if (this$._manual) {
|
|
1895
|
+
return;
|
|
1896
|
+
}
|
|
1897
|
+
this$._apply(this$.time());
|
|
1898
|
+
if (this$._list.size) {
|
|
1899
|
+
return this$._kick();
|
|
1900
|
+
}
|
|
1901
|
+
};
|
|
1902
|
+
return this;
|
|
1903
|
+
};
|
|
1904
|
+
anim.prototype = import$(Object.create(Object.prototype), {
|
|
1905
|
+
on: function(n, cb){
|
|
1906
|
+
var this$ = this;
|
|
1907
|
+
return (Array.isArray(n)
|
|
1908
|
+
? n
|
|
1909
|
+
: [n]).map(function(n){
|
|
1910
|
+
var ref$;
|
|
1911
|
+
return ((ref$ = this$.evtHandler)[n] || (ref$[n] = [])).push(cb);
|
|
1912
|
+
});
|
|
1913
|
+
},
|
|
1914
|
+
fire: function(n){
|
|
1915
|
+
var v, res$, i$, to$, ref$, len$, cb, results$ = [];
|
|
1916
|
+
res$ = [];
|
|
1917
|
+
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
|
|
1918
|
+
res$.push(arguments[i$]);
|
|
1919
|
+
}
|
|
1920
|
+
v = res$;
|
|
1921
|
+
for (i$ = 0, len$ = (ref$ = this.evtHandler[n] || []).length; i$ < len$; ++i$) {
|
|
1922
|
+
cb = ref$[i$];
|
|
1923
|
+
results$.push(cb.apply(this, v));
|
|
1924
|
+
}
|
|
1925
|
+
return results$;
|
|
1926
|
+
},
|
|
1927
|
+
time: function(){
|
|
1928
|
+
if (this._manual) {
|
|
1929
|
+
return this._now;
|
|
1930
|
+
} else {
|
|
1931
|
+
return now() - this._offset;
|
|
1932
|
+
}
|
|
1933
|
+
},
|
|
1934
|
+
manual: function(v){
|
|
1935
|
+
if (!arguments.length) {
|
|
1936
|
+
return this._manual;
|
|
1937
|
+
}
|
|
1938
|
+
v = !!v;
|
|
1939
|
+
if (v === this._manual) {
|
|
1940
|
+
return this;
|
|
1941
|
+
}
|
|
1942
|
+
if (v) {
|
|
1943
|
+
this._now = this.time();
|
|
1944
|
+
this._manual = true;
|
|
1945
|
+
if (this._raf) {
|
|
1946
|
+
cancelAnimationFrame(this._raf);
|
|
1947
|
+
}
|
|
1948
|
+
this._raf = null;
|
|
1949
|
+
} else {
|
|
1950
|
+
this._offset = now() - this._now;
|
|
1951
|
+
this._manual = false;
|
|
1952
|
+
if (this._list.size) {
|
|
1953
|
+
this._kick();
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
return this;
|
|
1957
|
+
},
|
|
1958
|
+
step: function(dt){
|
|
1959
|
+
dt == null && (dt = 1000 / 60);
|
|
1960
|
+
if (!this._manual) {
|
|
1961
|
+
this.manual(true);
|
|
1962
|
+
}
|
|
1963
|
+
this._now += dt;
|
|
1964
|
+
this._apply(this._now);
|
|
1965
|
+
this.fire('step', this._now, dt);
|
|
1966
|
+
return this;
|
|
1967
|
+
},
|
|
1968
|
+
seek: function(t){
|
|
1969
|
+
if (!this._manual) {
|
|
1970
|
+
this.manual(true);
|
|
1971
|
+
}
|
|
1972
|
+
this._now = t;
|
|
1973
|
+
this._apply(this._now);
|
|
1974
|
+
this.fire('step', this._now, 0);
|
|
1975
|
+
return this;
|
|
1976
|
+
},
|
|
1977
|
+
busy: function(){
|
|
1978
|
+
return this._list.size > 0;
|
|
1979
|
+
},
|
|
1980
|
+
flush: function(){
|
|
1981
|
+
this._apply(Infinity);
|
|
1982
|
+
return this;
|
|
1983
|
+
},
|
|
1984
|
+
interrupt: function(node){
|
|
1985
|
+
return this._list['delete'](node);
|
|
1986
|
+
},
|
|
1987
|
+
_kick: function(){
|
|
1988
|
+
var this$ = this;
|
|
1989
|
+
if (this._manual || this._raf) {
|
|
1990
|
+
return;
|
|
1991
|
+
}
|
|
1992
|
+
if (!(typeof requestAnimationFrame != 'undefined' && requestAnimationFrame !== null)) {
|
|
1993
|
+
return setTimeout(function(){
|
|
1994
|
+
return this$._tick();
|
|
1995
|
+
}, 16);
|
|
1996
|
+
}
|
|
1997
|
+
return this._raf = requestAnimationFrame(this._tick);
|
|
1998
|
+
},
|
|
1999
|
+
tween: function(node, attrs, opt){
|
|
2000
|
+
var dur, delay, ez, immediate, item, start, k, v;
|
|
2001
|
+
attrs == null && (attrs = {});
|
|
2002
|
+
opt == null && (opt = {});
|
|
2003
|
+
dur = opt.duration != null ? opt.duration : 350;
|
|
2004
|
+
delay = opt.delay || 0;
|
|
2005
|
+
ez = typeof opt.ease === 'function'
|
|
2006
|
+
? opt.ease
|
|
2007
|
+
: ease[opt.ease || 'cubic-in-out'] || ease.cubicInOut;
|
|
2008
|
+
immediate = (dur <= 0 && delay <= 0) || (!this._manual && (typeof document != 'undefined' && document !== null) && document.hidden);
|
|
2009
|
+
item = this._list.get(node) || {
|
|
2010
|
+
attr: {},
|
|
2011
|
+
cb: []
|
|
2012
|
+
};
|
|
2013
|
+
item.remove = !!opt.remove;
|
|
2014
|
+
if (opt.end) {
|
|
2015
|
+
item.cb.push(opt.end);
|
|
2016
|
+
}
|
|
2017
|
+
start = this.time() + delay;
|
|
2018
|
+
for (k in attrs) {
|
|
2019
|
+
v = attrs[k];
|
|
2020
|
+
if (!(v != null)) {
|
|
2021
|
+
node.removeAttribute(k);
|
|
2022
|
+
delete item.attr[k];
|
|
2023
|
+
continue;
|
|
2024
|
+
}
|
|
2025
|
+
if (immediate) {
|
|
2026
|
+
node.setAttribute(k, v);
|
|
2027
|
+
delete item.attr[k];
|
|
2028
|
+
} else {
|
|
2029
|
+
item.attr[k] = {
|
|
2030
|
+
to: v,
|
|
2031
|
+
start: start,
|
|
2032
|
+
dur: dur > 0 ? dur : 0,
|
|
2033
|
+
ease: ez
|
|
2034
|
+
};
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
this._list.set(node, item);
|
|
2038
|
+
if (immediate && !(function(){
|
|
2039
|
+
var results$ = [];
|
|
2040
|
+
for (k in item.attr) {
|
|
2041
|
+
results$.push(k);
|
|
2042
|
+
}
|
|
2043
|
+
return results$;
|
|
2044
|
+
}()).length) {
|
|
2045
|
+
this._done(node, item);
|
|
2046
|
+
} else if (!this._manual) {
|
|
2047
|
+
this._kick();
|
|
2048
|
+
}
|
|
2049
|
+
return this;
|
|
2050
|
+
},
|
|
2051
|
+
_done: function(node, item){
|
|
2052
|
+
this._list['delete'](node);
|
|
2053
|
+
if (item.remove && node.parentNode) {
|
|
2054
|
+
node.parentNode.removeChild(node);
|
|
2055
|
+
}
|
|
2056
|
+
return item.cb.map(function(it){
|
|
2057
|
+
return it.call(node);
|
|
2058
|
+
});
|
|
2059
|
+
},
|
|
2060
|
+
_apply: function(t){
|
|
2061
|
+
var i$, ref$, len$, ref1$, node, item, k, a, p, ref2$, results$ = [];
|
|
2062
|
+
for (i$ = 0, len$ = (ref$ = Array.from(this._list)).length; i$ < len$; ++i$) {
|
|
2063
|
+
ref1$ = ref$[i$], node = ref1$[0], item = ref1$[1];
|
|
2064
|
+
if (this._list.get(node) !== item) {
|
|
2065
|
+
continue;
|
|
2066
|
+
}
|
|
2067
|
+
for (k in ref1$ = item.attr) {
|
|
2068
|
+
a = ref1$[k];
|
|
2069
|
+
if (t < a.start) {
|
|
2070
|
+
continue;
|
|
2071
|
+
}
|
|
2072
|
+
if (!a.interp) {
|
|
2073
|
+
a.interp = interpolate(node.getAttribute(k), a.to);
|
|
2074
|
+
}
|
|
2075
|
+
p = a.dur ? (ref2$ = (t - a.start) / a.dur) < 1 ? ref2$ : 1 : 1;
|
|
2076
|
+
if (p >= 1) {
|
|
2077
|
+
node.setAttribute(k, a.to);
|
|
2078
|
+
delete item.attr[k];
|
|
2079
|
+
} else {
|
|
2080
|
+
node.setAttribute(k, a.interp(a.ease(p)));
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
if (!(fn$()).length) {
|
|
2084
|
+
results$.push(this._done(node, item));
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
return results$;
|
|
2088
|
+
function fn$(){
|
|
2089
|
+
var results$ = [];
|
|
2090
|
+
for (k in item.attr) {
|
|
2091
|
+
results$.push(k);
|
|
2092
|
+
}
|
|
2093
|
+
return results$;
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
});
|
|
2097
|
+
join = function(arg$){
|
|
2098
|
+
var root, tag, ref$, cls, data, key, olds, map, enter, update, nodes, exit;
|
|
2099
|
+
root = arg$.root, tag = (ref$ = arg$.tag) != null ? ref$ : 'g', cls = arg$.cls, data = (ref$ = arg$.data) != null
|
|
2100
|
+
? ref$
|
|
2101
|
+
: [], key = arg$.key;
|
|
2102
|
+
key = key || function(d, i){
|
|
2103
|
+
return i;
|
|
2104
|
+
};
|
|
2105
|
+
olds = Array.from(root.childNodes).filter(function(n){
|
|
2106
|
+
return n.nodeType === 1 && n.tagName === tag && (!cls || n.classList.contains(cls));
|
|
2107
|
+
});
|
|
2108
|
+
map = new Map();
|
|
2109
|
+
ref$ = [[], [], [], []], enter = ref$[0], update = ref$[1], nodes = ref$[2], exit = ref$[3];
|
|
2110
|
+
olds.map(function(n, i){
|
|
2111
|
+
var k;
|
|
2112
|
+
k = key(n.__data__, i);
|
|
2113
|
+
if (map.has(k)) {
|
|
2114
|
+
return exit.push(n);
|
|
2115
|
+
} else {
|
|
2116
|
+
return map.set(k, n);
|
|
2117
|
+
}
|
|
2118
|
+
});
|
|
2119
|
+
data.map(function(d, i){
|
|
2120
|
+
var k, n;
|
|
2121
|
+
k = key(d, i);
|
|
2122
|
+
if (n = map.get(k)) {
|
|
2123
|
+
map['delete'](k);
|
|
2124
|
+
update.push(n);
|
|
2125
|
+
} else {
|
|
2126
|
+
n = document.createElementNS(svgns, tag);
|
|
2127
|
+
if (cls) {
|
|
2128
|
+
n.setAttribute('class', cls);
|
|
2129
|
+
}
|
|
2130
|
+
root.appendChild(n);
|
|
2131
|
+
enter.push(n);
|
|
2132
|
+
}
|
|
2133
|
+
n.__data__ = d;
|
|
2134
|
+
return nodes.push(n);
|
|
2135
|
+
});
|
|
2136
|
+
exit = exit.concat(Array.from(map.values()));
|
|
2137
|
+
return {
|
|
2138
|
+
enter: enter,
|
|
2139
|
+
update: update,
|
|
2140
|
+
exit: exit,
|
|
2141
|
+
nodes: nodes
|
|
2142
|
+
};
|
|
2143
|
+
};
|
|
2144
|
+
anim.ease = ease;
|
|
2145
|
+
anim.interpolate = interpolate;
|
|
2146
|
+
anim.join = join;
|
|
2147
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
2148
|
+
(chart.utils || (chart.utils = {})).anim = anim;
|
|
2149
|
+
}
|
|
2150
|
+
function import$(obj, src){
|
|
2151
|
+
var own = {}.hasOwnProperty;
|
|
2152
|
+
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
|
2153
|
+
return obj;
|
|
2154
|
+
}
|
|
2155
|
+
}).call(this);
|
|
2156
|
+
(function(){
|
|
2157
|
+
var svgns, handleSize, brush;
|
|
2158
|
+
svgns = "http://www.w3.org/2000/svg";
|
|
2159
|
+
handleSize = 6;
|
|
2160
|
+
brush = function(opt){
|
|
2161
|
+
opt == null && (opt = {});
|
|
2162
|
+
this.dir = opt.dir === 'y' ? 'y' : 'x';
|
|
2163
|
+
this._extent = [[0, 0], [1, 1]];
|
|
2164
|
+
this._sel = null;
|
|
2165
|
+
this._g = null;
|
|
2166
|
+
this.evtHandler = {};
|
|
2167
|
+
return this;
|
|
2168
|
+
};
|
|
2169
|
+
brush.prototype = import$(Object.create(Object.prototype), {
|
|
2170
|
+
on: function(n, cb){
|
|
2171
|
+
var this$ = this;
|
|
2172
|
+
return (Array.isArray(n)
|
|
2173
|
+
? n
|
|
2174
|
+
: [n]).map(function(n){
|
|
2175
|
+
var ref$;
|
|
2176
|
+
return ((ref$ = this$.evtHandler)[n] || (ref$[n] = [])).push(cb);
|
|
2177
|
+
});
|
|
2178
|
+
},
|
|
2179
|
+
fire: function(n){
|
|
2180
|
+
var v, res$, i$, to$, ref$, len$, cb, results$ = [];
|
|
2181
|
+
res$ = [];
|
|
2182
|
+
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
|
|
2183
|
+
res$.push(arguments[i$]);
|
|
2184
|
+
}
|
|
2185
|
+
v = res$;
|
|
2186
|
+
for (i$ = 0, len$ = (ref$ = this.evtHandler[n] || []).length; i$ < len$; ++i$) {
|
|
2187
|
+
cb = ref$[i$];
|
|
2188
|
+
results$.push(cb.apply(this, v));
|
|
2189
|
+
}
|
|
2190
|
+
return results$;
|
|
2191
|
+
},
|
|
2192
|
+
extent: function(e){
|
|
2193
|
+
if (!arguments.length) {
|
|
2194
|
+
return this._extent;
|
|
2195
|
+
}
|
|
2196
|
+
this._extent = e;
|
|
2197
|
+
this._render();
|
|
2198
|
+
return this;
|
|
2199
|
+
},
|
|
2200
|
+
selection: function(){
|
|
2201
|
+
if (this._sel) {
|
|
2202
|
+
return this._sel.slice();
|
|
2203
|
+
} else {
|
|
2204
|
+
return null;
|
|
2205
|
+
}
|
|
2206
|
+
},
|
|
2207
|
+
attached: function(){
|
|
2208
|
+
return !!this._g;
|
|
2209
|
+
},
|
|
2210
|
+
_span: function(){
|
|
2211
|
+
var i;
|
|
2212
|
+
i = this.dir === 'x' ? 0 : 1;
|
|
2213
|
+
return [this._extent[0][i], this._extent[1][i]];
|
|
2214
|
+
},
|
|
2215
|
+
_emit: function(type, evt){
|
|
2216
|
+
return this.fire(type, {
|
|
2217
|
+
type: type,
|
|
2218
|
+
selection: this.selection(),
|
|
2219
|
+
sourceEvent: evt || null,
|
|
2220
|
+
target: this
|
|
2221
|
+
});
|
|
2222
|
+
},
|
|
2223
|
+
move: function(sel, evt){
|
|
2224
|
+
var this$ = this;
|
|
2225
|
+
this._sel = sel != null ? [+sel[0], +sel[1]] : null;
|
|
2226
|
+
this._render();
|
|
2227
|
+
['start', 'brush', 'end'].map(function(it){
|
|
2228
|
+
return this$._emit(it, evt);
|
|
2229
|
+
});
|
|
2230
|
+
return this;
|
|
2231
|
+
},
|
|
2232
|
+
clear: function(evt){
|
|
2233
|
+
return this.move(null, evt);
|
|
2234
|
+
},
|
|
2235
|
+
attach: function(g){
|
|
2236
|
+
var mk, ends, cursor, this$ = this;
|
|
2237
|
+
if (this._g !== g) {
|
|
2238
|
+
if (this._g) {
|
|
2239
|
+
this.detach();
|
|
2240
|
+
}
|
|
2241
|
+
if (g.__brush && g.__brush !== this) {
|
|
2242
|
+
g.__brush.detach();
|
|
2243
|
+
}
|
|
2244
|
+
g.__brush = this;
|
|
2245
|
+
this._g = g;
|
|
2246
|
+
g.setAttribute('fill', 'none');
|
|
2247
|
+
g.setAttribute('pointer-events', 'all');
|
|
2248
|
+
g.style.touchAction = 'none';
|
|
2249
|
+
g.style.webkitTapHighlightColor = "rgba(0,0,0,0)";
|
|
2250
|
+
mk = function(cls, type, attrs){
|
|
2251
|
+
var n, k, v;
|
|
2252
|
+
attrs == null && (attrs = {});
|
|
2253
|
+
n = g.querySelector(":scope > rect." + cls.split(' ').join('.')) || g.appendChild(document.createElementNS(svgns, 'rect'));
|
|
2254
|
+
n.setAttribute('class', cls);
|
|
2255
|
+
n.__data__ = {
|
|
2256
|
+
type: type
|
|
2257
|
+
};
|
|
2258
|
+
for (k in attrs) {
|
|
2259
|
+
v = attrs[k];
|
|
2260
|
+
n.setAttribute(k, v);
|
|
2261
|
+
}
|
|
2262
|
+
return n;
|
|
2263
|
+
};
|
|
2264
|
+
ends = this.dir === 'x'
|
|
2265
|
+
? ['w', 'e']
|
|
2266
|
+
: ['n', 's'];
|
|
2267
|
+
cursor = this.dir === 'x' ? 'ew-resize' : 'ns-resize';
|
|
2268
|
+
this._n = {
|
|
2269
|
+
overlay: mk('overlay', 'overlay', {
|
|
2270
|
+
"pointer-events": 'all',
|
|
2271
|
+
cursor: 'crosshair'
|
|
2272
|
+
}),
|
|
2273
|
+
selection: mk('selection', 'selection', {
|
|
2274
|
+
cursor: 'move',
|
|
2275
|
+
fill: '#777',
|
|
2276
|
+
"fill-opacity": 0.3,
|
|
2277
|
+
stroke: '#fff',
|
|
2278
|
+
"shape-rendering": 'crispEdges'
|
|
2279
|
+
}),
|
|
2280
|
+
handle: ends.map(function(t){
|
|
2281
|
+
return mk("handle handle--" + t, t, {
|
|
2282
|
+
cursor: cursor
|
|
2283
|
+
});
|
|
2284
|
+
})
|
|
2285
|
+
};
|
|
2286
|
+
g.addEventListener('pointerdown', this._down = function(e){
|
|
2287
|
+
return this$._start(e);
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
this._render();
|
|
2291
|
+
return this;
|
|
2292
|
+
},
|
|
2293
|
+
detach: function(){
|
|
2294
|
+
var i$, ref$, len$, n;
|
|
2295
|
+
if (!this._g) {
|
|
2296
|
+
return;
|
|
2297
|
+
}
|
|
2298
|
+
this._g.removeEventListener('pointerdown', this._down);
|
|
2299
|
+
for (i$ = 0, len$ = (ref$ = [this._n.overlay, this._n.selection].concat(this._n.handle)).length; i$ < len$; ++i$) {
|
|
2300
|
+
n = ref$[i$];
|
|
2301
|
+
if (n.parentNode) {
|
|
2302
|
+
n.parentNode.removeChild(n);
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
if (this._g.__brush === this) {
|
|
2306
|
+
this._g.__brush = null;
|
|
2307
|
+
}
|
|
2308
|
+
return this._g = null;
|
|
2309
|
+
},
|
|
2310
|
+
_render: function(){
|
|
2311
|
+
var ref$, ref1$, x0, y0, x1, y1, x$, i$, len$, n, a, b, sx0, sy0, sx1, sy1, y$, h, this$ = this;
|
|
2312
|
+
if (!this._g) {
|
|
2313
|
+
return;
|
|
2314
|
+
}
|
|
2315
|
+
ref$ = this._extent, ref1$ = ref$[0], x0 = ref1$[0], y0 = ref1$[1], ref1$ = ref$[1], x1 = ref1$[0], y1 = ref1$[1];
|
|
2316
|
+
x$ = this._n.overlay;
|
|
2317
|
+
x$.setAttribute('x', x0);
|
|
2318
|
+
x$.setAttribute('y', y0);
|
|
2319
|
+
x$.setAttribute('width', x1 - x0);
|
|
2320
|
+
x$.setAttribute('height', y1 - y0);
|
|
2321
|
+
if (!this._sel) {
|
|
2322
|
+
for (i$ = 0, len$ = (ref$ = [this._n.selection].concat(this._n.handle)).length; i$ < len$; ++i$) {
|
|
2323
|
+
n = ref$[i$];
|
|
2324
|
+
n.style.display = 'none';
|
|
2325
|
+
['x', 'y', 'width', 'height'].map(fn$);
|
|
2326
|
+
}
|
|
2327
|
+
return;
|
|
2328
|
+
}
|
|
2329
|
+
ref$ = this._sel, a = ref$[0], b = ref$[1];
|
|
2330
|
+
ref$ = this.dir === 'x'
|
|
2331
|
+
? [a, y0, b, y1]
|
|
2332
|
+
: [x0, a, x1, b], sx0 = ref$[0], sy0 = ref$[1], sx1 = ref$[2], sy1 = ref$[3];
|
|
2333
|
+
y$ = this._n.selection;
|
|
2334
|
+
y$.style.display = '';
|
|
2335
|
+
y$.setAttribute('x', sx0);
|
|
2336
|
+
y$.setAttribute('y', sy0);
|
|
2337
|
+
y$.setAttribute('width', sx1 - sx0);
|
|
2338
|
+
y$.setAttribute('height', sy1 - sy0);
|
|
2339
|
+
h = handleSize / 2;
|
|
2340
|
+
return this._n.handle.map(function(n, i){
|
|
2341
|
+
n.style.display = '';
|
|
2342
|
+
if (this$.dir === 'x') {
|
|
2343
|
+
n.setAttribute('x', (i ? sx1 : sx0) - h);
|
|
2344
|
+
n.setAttribute('y', sy0 - h);
|
|
2345
|
+
n.setAttribute('width', handleSize);
|
|
2346
|
+
return n.setAttribute('height', sy1 - sy0 + handleSize);
|
|
2347
|
+
} else {
|
|
2348
|
+
n.setAttribute('x', sx0 - h);
|
|
2349
|
+
n.setAttribute('y', (i ? sy1 : sy0) - h);
|
|
2350
|
+
n.setAttribute('width', sx1 - sx0 + handleSize);
|
|
2351
|
+
return n.setAttribute('height', handleSize);
|
|
2352
|
+
}
|
|
2353
|
+
});
|
|
2354
|
+
function fn$(it){
|
|
2355
|
+
return n.removeAttribute(it);
|
|
2356
|
+
}
|
|
2357
|
+
},
|
|
2358
|
+
_pos: function(e){
|
|
2359
|
+
var m, p;
|
|
2360
|
+
m = this._g.getScreenCTM();
|
|
2361
|
+
if (!m) {
|
|
2362
|
+
return 0;
|
|
2363
|
+
}
|
|
2364
|
+
p = new DOMPoint(e.clientX, e.clientY).matrixTransform(m.inverse());
|
|
2365
|
+
if (this.dir === 'x') {
|
|
2366
|
+
return p.x;
|
|
2367
|
+
} else {
|
|
2368
|
+
return p.y;
|
|
2369
|
+
}
|
|
2370
|
+
},
|
|
2371
|
+
_start: function(e){
|
|
2372
|
+
var type, ref$, lo, hi, clamp, p0, s0, mode, moved, upd, mv, up, this$ = this;
|
|
2373
|
+
if (e.button != null && e.button !== 0) {
|
|
2374
|
+
return;
|
|
2375
|
+
}
|
|
2376
|
+
type = (e.target.__data__ || {}).type;
|
|
2377
|
+
if (!type) {
|
|
2378
|
+
return;
|
|
2379
|
+
}
|
|
2380
|
+
e.stopImmediatePropagation();
|
|
2381
|
+
e.preventDefault();
|
|
2382
|
+
ref$ = this._span(), lo = ref$[0], hi = ref$[1];
|
|
2383
|
+
clamp = function(v){
|
|
2384
|
+
var ref$;
|
|
2385
|
+
return (ref$ = v > lo ? v : lo) < hi ? ref$ : hi;
|
|
2386
|
+
};
|
|
2387
|
+
p0 = this._pos(e);
|
|
2388
|
+
s0 = this._sel ? this._sel.slice() : null;
|
|
2389
|
+
mode = type === 'selection'
|
|
2390
|
+
? 'move'
|
|
2391
|
+
: (type === 'w' || type === 'n') && s0
|
|
2392
|
+
? 'lo'
|
|
2393
|
+
: (type === 'e' || type === 's') && s0 ? 'hi' : 'new';
|
|
2394
|
+
if (mode === 'new') {
|
|
2395
|
+
p0 = clamp(p0);
|
|
2396
|
+
}
|
|
2397
|
+
moved = false;
|
|
2398
|
+
this._emit('start', e);
|
|
2399
|
+
upd = function(e){
|
|
2400
|
+
var p, d, ref$, ref1$, ref2$, anchor;
|
|
2401
|
+
p = this$._pos(e);
|
|
2402
|
+
if (mode === 'move') {
|
|
2403
|
+
d = p - p0;
|
|
2404
|
+
d = (ref$ = d > (ref2$ = lo - s0[0]) ? d : ref2$) < (ref1$ = hi - s0[1]) ? ref$ : ref1$;
|
|
2405
|
+
this$._sel = [s0[0] + d, s0[1] + d];
|
|
2406
|
+
} else {
|
|
2407
|
+
anchor = mode === 'new'
|
|
2408
|
+
? p0
|
|
2409
|
+
: mode === 'lo'
|
|
2410
|
+
? s0[1]
|
|
2411
|
+
: s0[0];
|
|
2412
|
+
p = clamp(p);
|
|
2413
|
+
this$._sel = [Math.min(anchor, p), Math.max(anchor, p)];
|
|
2414
|
+
}
|
|
2415
|
+
this$._render();
|
|
2416
|
+
return this$._emit('brush', e);
|
|
2417
|
+
};
|
|
2418
|
+
mv = function(e){
|
|
2419
|
+
moved = true;
|
|
2420
|
+
return upd(e);
|
|
2421
|
+
};
|
|
2422
|
+
up = function(e){
|
|
2423
|
+
var noclick;
|
|
2424
|
+
window.removeEventListener('pointermove', mv);
|
|
2425
|
+
window.removeEventListener('pointerup', up);
|
|
2426
|
+
window.removeEventListener('pointercancel', up);
|
|
2427
|
+
if (!moved && mode !== 'move') {
|
|
2428
|
+
this$._sel = null;
|
|
2429
|
+
}
|
|
2430
|
+
if (this$._sel && this$._sel[0] === this$._sel[1]) {
|
|
2431
|
+
this$._sel = null;
|
|
2432
|
+
}
|
|
2433
|
+
this$._render();
|
|
2434
|
+
if (moved) {
|
|
2435
|
+
noclick = function(e){
|
|
2436
|
+
e.stopImmediatePropagation();
|
|
2437
|
+
return e.preventDefault();
|
|
2438
|
+
};
|
|
2439
|
+
window.addEventListener('click', noclick, true);
|
|
2440
|
+
setTimeout(function(){
|
|
2441
|
+
return window.removeEventListener('click', noclick, true);
|
|
2442
|
+
}, 0);
|
|
2443
|
+
}
|
|
2444
|
+
return this$._emit('end', e);
|
|
2445
|
+
};
|
|
2446
|
+
window.addEventListener('pointermove', mv);
|
|
2447
|
+
window.addEventListener('pointerup', up);
|
|
2448
|
+
return window.addEventListener('pointercancel', up);
|
|
2449
|
+
}
|
|
2450
|
+
});
|
|
2451
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
2452
|
+
(chart.utils || (chart.utils = {})).brush = brush;
|
|
2453
|
+
}
|
|
2454
|
+
function import$(obj, src){
|
|
2455
|
+
var own = {}.hasOwnProperty;
|
|
2456
|
+
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
|
2457
|
+
return obj;
|
|
2458
|
+
}
|
|
2459
|
+
}).call(this);
|
|
2460
|
+
(function(){
|
|
2461
|
+
var tint;
|
|
2462
|
+
tint = function(opt){
|
|
2463
|
+
opt == null && (opt = {});
|
|
2464
|
+
this.isUnique = opt.unique != null ? opt.unique : true;
|
|
2465
|
+
this.map = {};
|
|
2466
|
+
this.nmap = [];
|
|
2467
|
+
this.wm = new WeakMap();
|
|
2468
|
+
this.count = 0;
|
|
2469
|
+
this._ext = opt.extent || [0, 1];
|
|
2470
|
+
this.set(opt.palette) || opt.colors;
|
|
2471
|
+
this.mode(opt.mode) || 0;
|
|
2472
|
+
return this;
|
|
2473
|
+
};
|
|
2474
|
+
tint['default'] = ['#e15c64', '#f7b26a', '#f3ed9d', '#a4bd81', '#a0d7d2', '#8db1da', '#daaedb'];
|
|
2475
|
+
tint.prototype = import$(Object.create(Object.prototype), {
|
|
2476
|
+
set: function(pal){
|
|
2477
|
+
var key, reset, ref$, this$ = this;
|
|
2478
|
+
pal == null && (pal = []);
|
|
2479
|
+
key = pal.key || pal.name;
|
|
2480
|
+
if (!(typeof reset != 'undefined' && reset !== null)) {
|
|
2481
|
+
reset = key != null && this.key !== key ? true : false;
|
|
2482
|
+
}
|
|
2483
|
+
this.key = key;
|
|
2484
|
+
this.colors = Array.isArray(pal) && pal.length
|
|
2485
|
+
? pal
|
|
2486
|
+
: pal.colors && Array.isArray(pal.colors)
|
|
2487
|
+
? pal.colors
|
|
2488
|
+
: tint['default'];
|
|
2489
|
+
this.nmap = pal.maps || [];
|
|
2490
|
+
this.tags = this.colors.map(function(it){
|
|
2491
|
+
return it.tag || [];
|
|
2492
|
+
});
|
|
2493
|
+
this.colors = this.colors.map(function(it){
|
|
2494
|
+
return it.value || it;
|
|
2495
|
+
});
|
|
2496
|
+
if (this.colors.length === 1) {
|
|
2497
|
+
this.colors.push(ldcolor.complement(this.colors[0]));
|
|
2498
|
+
}
|
|
2499
|
+
this.colors = this.colors.map(function(it){
|
|
2500
|
+
return ldcolor.hsl(it);
|
|
2501
|
+
});
|
|
2502
|
+
this.len = (ref$ = this.colors.length) > 2 ? ref$ : 2;
|
|
2503
|
+
if (reset) {
|
|
2504
|
+
this.reset();
|
|
2505
|
+
} else {
|
|
2506
|
+
this.nmap.map(function(d, i){
|
|
2507
|
+
return (Array.isArray(d)
|
|
2508
|
+
? d
|
|
2509
|
+
: [d]).map(function(it){
|
|
2510
|
+
return this$.get(it, 0, i);
|
|
2511
|
+
});
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
return this.tags.map(function(t, i){
|
|
2515
|
+
return t.map(function(it){
|
|
2516
|
+
return this$.get(it, 0, i);
|
|
2517
|
+
});
|
|
2518
|
+
});
|
|
2519
|
+
},
|
|
2520
|
+
unique: function(it){
|
|
2521
|
+
return it != null
|
|
2522
|
+
? this.isUnique = !!it
|
|
2523
|
+
: this.isUnique;
|
|
2524
|
+
},
|
|
2525
|
+
reset: function(){
|
|
2526
|
+
var this$ = this;
|
|
2527
|
+
this.map = {};
|
|
2528
|
+
this.wm = new WeakMap();
|
|
2529
|
+
this.count = 0;
|
|
2530
|
+
return (this.nmap || []).map(function(d, i){
|
|
2531
|
+
return (Array.isArray(d)
|
|
2532
|
+
? d
|
|
2533
|
+
: [d]).map(function(it){
|
|
2534
|
+
return this$.get(it, 0, i);
|
|
2535
|
+
});
|
|
2536
|
+
});
|
|
2537
|
+
},
|
|
2538
|
+
mode: function(m){
|
|
2539
|
+
if (arguments.length === 0) {
|
|
2540
|
+
return this._m;
|
|
2541
|
+
}
|
|
2542
|
+
return this._m = m;
|
|
2543
|
+
},
|
|
2544
|
+
extent: function(v){
|
|
2545
|
+
if (arguments.length === 0) {
|
|
2546
|
+
return this._ext;
|
|
2547
|
+
}
|
|
2548
|
+
this._ext = v.map(function(it){
|
|
2549
|
+
if (it != null) {
|
|
2550
|
+
return it;
|
|
2551
|
+
} else {
|
|
2552
|
+
return 0;
|
|
2553
|
+
}
|
|
2554
|
+
});
|
|
2555
|
+
return this._ext.sort(function(a, b){
|
|
2556
|
+
return a - b;
|
|
2557
|
+
});
|
|
2558
|
+
},
|
|
2559
|
+
get: function(d, v, i){
|
|
2560
|
+
v == null && (v = 0);
|
|
2561
|
+
switch (this._m) {
|
|
2562
|
+
case 1:
|
|
2563
|
+
return this._vd(d, v);
|
|
2564
|
+
case 2:
|
|
2565
|
+
return this._vc(d, v);
|
|
2566
|
+
case 3:
|
|
2567
|
+
return this._vs(d, v);
|
|
2568
|
+
default:
|
|
2569
|
+
return this._d(d, v, i);
|
|
2570
|
+
}
|
|
2571
|
+
},
|
|
2572
|
+
_v: function(c, v){
|
|
2573
|
+
if (v > 0) {
|
|
2574
|
+
c = ldcolor.lighter(c, v);
|
|
2575
|
+
} else if (v < 0) {
|
|
2576
|
+
c = ldcolor.darker(c, -v);
|
|
2577
|
+
}
|
|
2578
|
+
return ldcolor.web(c);
|
|
2579
|
+
},
|
|
2580
|
+
_d: function(data, variant, idx){
|
|
2581
|
+
var val, seg, pos, ref$, fz, fm, c1, c2, h, s, l, ret;
|
|
2582
|
+
variant == null && (variant = 0);
|
|
2583
|
+
if (idx != null) {
|
|
2584
|
+
if (this.count < idx) {
|
|
2585
|
+
this.count = idx + 1;
|
|
2586
|
+
}
|
|
2587
|
+
val = idx % this.len;
|
|
2588
|
+
if (typeof data === 'object') {
|
|
2589
|
+
this.wm.set(data, val);
|
|
2590
|
+
} else {
|
|
2591
|
+
this.map[data] = val;
|
|
2592
|
+
}
|
|
2593
|
+
} else {
|
|
2594
|
+
if (typeof data === 'object') {
|
|
2595
|
+
if ((val = this.wm.get(data)) == null) {
|
|
2596
|
+
this.wm.set(data, val = this.count++);
|
|
2597
|
+
}
|
|
2598
|
+
} else if ((val = this.map[data]) == null) {
|
|
2599
|
+
this.map[data] = val = this.count++;
|
|
2600
|
+
}
|
|
2601
|
+
if (!this.isUnique) {
|
|
2602
|
+
val = val % this.len;
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
if (val >= this.len) {
|
|
2606
|
+
seg = val % (this.len - 1);
|
|
2607
|
+
pos = Math.floor(val / (this.len - 1));
|
|
2608
|
+
ref$ = [0, 1], fz = ref$[0], fm = ref$[1];
|
|
2609
|
+
while (pos > 0) {
|
|
2610
|
+
ref$ = [fz * 2, fm * 2], fz = ref$[0], fm = ref$[1];
|
|
2611
|
+
if (pos % 2) {
|
|
2612
|
+
fz += 1;
|
|
2613
|
+
}
|
|
2614
|
+
pos = pos >> 1;
|
|
2615
|
+
}
|
|
2616
|
+
pos = fz / fm;
|
|
2617
|
+
ref$ = [this.colors[seg], this.colors[seg + 1]], c1 = ref$[0], c2 = ref$[1];
|
|
2618
|
+
ref$ = ['h', 's', 'l'].map(function(k){
|
|
2619
|
+
return pos * (c2[k] - c1[k]) + c1[k];
|
|
2620
|
+
}), h = ref$[0], s = ref$[1], l = ref$[2];
|
|
2621
|
+
ret = {
|
|
2622
|
+
h: h,
|
|
2623
|
+
s: s,
|
|
2624
|
+
l: l
|
|
2625
|
+
};
|
|
2626
|
+
} else {
|
|
2627
|
+
ret = this.colors[val];
|
|
2628
|
+
}
|
|
2629
|
+
return this._v(ret, variant);
|
|
2630
|
+
},
|
|
2631
|
+
_vs: function(data, variant){
|
|
2632
|
+
var ext, idx, i$, to$, i, ref$, ref1$;
|
|
2633
|
+
ext = this._ext || [0, 1];
|
|
2634
|
+
idx = -1;
|
|
2635
|
+
for (i$ = 0, to$ = ext.length - 1; i$ < to$; ++i$) {
|
|
2636
|
+
i = i$;
|
|
2637
|
+
if (data >= ext[i + 1]) {
|
|
2638
|
+
continue;
|
|
2639
|
+
}
|
|
2640
|
+
idx = i;
|
|
2641
|
+
break;
|
|
2642
|
+
}
|
|
2643
|
+
if (idx === -1) {
|
|
2644
|
+
idx = ext.length;
|
|
2645
|
+
}
|
|
2646
|
+
return this._v(this.colors[(ref$ = idx > 0 ? idx : 0) < (ref1$ = this.colors.length - 1) ? ref$ : ref1$], variant);
|
|
2647
|
+
},
|
|
2648
|
+
_vd: function(data, variant){
|
|
2649
|
+
var ext, v, ref$, ref1$;
|
|
2650
|
+
ext = this._ext || [0, 1];
|
|
2651
|
+
v = (ref$ = (ref1$ = (data - ext[0]) / (ext[1] - ext[0] || 1)) > 0 ? ref1$ : 0) < 1 ? ref$ : 1;
|
|
2652
|
+
return this._v(this.colors[Math.floor((ref$ = v * (this.len || 1)) < (ref1$ = this.len - 1) ? ref$ : ref1$)], variant);
|
|
2653
|
+
},
|
|
2654
|
+
_vc: function(data, variant){
|
|
2655
|
+
var ext, v, ref$, ref1$, i, i1, i2, c1, c2, pos, h, s, l;
|
|
2656
|
+
ext = this._ext || [0, 1];
|
|
2657
|
+
v = (ref$ = (ref1$ = (data - ext[0]) / (ext[1] - ext[0] || 1)) > 0 ? ref1$ : 0) < 1 ? ref$ : 1;
|
|
2658
|
+
i = v * ((ref$ = this.len - 1) > 0 ? ref$ : 0);
|
|
2659
|
+
ref$ = i === this.len - 1
|
|
2660
|
+
? [(ref$ = this.len - 2) > 0 ? ref$ : 0, (ref$ = this.len - 1) > 0 ? ref$ : 0]
|
|
2661
|
+
: [Math.floor(i), Math.floor(i) + 1], i1 = ref$[0], i2 = ref$[1];
|
|
2662
|
+
ref$ = [this.colors[i1], this.colors[i2]], c1 = ref$[0], c2 = ref$[1];
|
|
2663
|
+
pos = i - i1;
|
|
2664
|
+
ref$ = ['h', 's', 'l'].map(function(k){
|
|
2665
|
+
return pos * (c2[k] - c1[k]) + c1[k];
|
|
2666
|
+
}), h = ref$[0], s = ref$[1], l = ref$[2];
|
|
2667
|
+
return this._v({
|
|
2668
|
+
h: h,
|
|
2669
|
+
s: s,
|
|
2670
|
+
l: l
|
|
2671
|
+
}, variant);
|
|
2672
|
+
},
|
|
2673
|
+
text: function(v, opt){
|
|
2674
|
+
var hcl;
|
|
2675
|
+
opt == null && (opt = {});
|
|
2676
|
+
hcl = ldcolor.hcl(this.get(v));
|
|
2677
|
+
return ldcolor.web(hcl.l > 50
|
|
2678
|
+
? opt.textDark || '#000'
|
|
2679
|
+
: opt.textLight || '#fff');
|
|
2680
|
+
}
|
|
2681
|
+
});
|
|
2682
|
+
tint.mode = {
|
|
2683
|
+
ordinal: 0,
|
|
2684
|
+
discrete: 1,
|
|
2685
|
+
continuous: 2,
|
|
2686
|
+
ranges: 3
|
|
2687
|
+
};
|
|
2688
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
2689
|
+
(chart.utils || (chart.utils = {})).tint = tint;
|
|
2690
|
+
}
|
|
2691
|
+
function import$(obj, src){
|
|
2692
|
+
var own = {}.hasOwnProperty;
|
|
2693
|
+
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
|
2694
|
+
return obj;
|
|
2695
|
+
}
|
|
2696
|
+
}).call(this);
|
|
2697
|
+
(function(){
|
|
2698
|
+
var tick;
|
|
2699
|
+
tick = function(o){
|
|
2700
|
+
var ext, len, o_ext, gaps, ticks, steps, pow, delta, i$, i, g, s, j$, len$, j, step, ref$, ref1$, v, extent, base, lg, fmt, unit, labels, to$, t1, t2;
|
|
2701
|
+
o == null && (o = {});
|
|
2702
|
+
ext = o.extent || [0, 1];
|
|
2703
|
+
len = o.len || 3;
|
|
2704
|
+
ext = ext.map(function(it){
|
|
2705
|
+
if (!isNaN(it)) {
|
|
2706
|
+
return it;
|
|
2707
|
+
} else {
|
|
2708
|
+
return 0;
|
|
2709
|
+
}
|
|
2710
|
+
});
|
|
2711
|
+
if (ext[0] > ext[1]) {
|
|
2712
|
+
ext = [ext[1], ext[0]];
|
|
2713
|
+
}
|
|
2714
|
+
o_ext = ext;
|
|
2715
|
+
if (o.exp != null) {
|
|
2716
|
+
gaps = [10, 15, 20, 25, 30, 40, 50, 75, 100];
|
|
2717
|
+
ticks = [];
|
|
2718
|
+
steps = [];
|
|
2719
|
+
pow = Math.pow(10, o.exp);
|
|
2720
|
+
if (o.pretty != null && !o.pretty) {
|
|
2721
|
+
delta = ext[1] - ext[0];
|
|
2722
|
+
ticks = (function(){
|
|
2723
|
+
var i$, to$, results$ = [];
|
|
2724
|
+
for (i$ = 0, to$ = len; i$ <= to$; ++i$) {
|
|
2725
|
+
results$.push(i$);
|
|
2726
|
+
}
|
|
2727
|
+
return results$;
|
|
2728
|
+
}()).map(function(i){
|
|
2729
|
+
return delta * Math.pow(i / len, pow) + ext[0];
|
|
2730
|
+
});
|
|
2731
|
+
} else {
|
|
2732
|
+
ext = [[ext[0], 'floor'], [ext[1], 'ceil']].map(function(arg$){
|
|
2733
|
+
var t, n, ret;
|
|
2734
|
+
t = arg$[0], n = arg$[1];
|
|
2735
|
+
ret = gaps.map(function(d){
|
|
2736
|
+
return [d, Math.abs(t - Math[n](t / d) * d)];
|
|
2737
|
+
});
|
|
2738
|
+
ret.sort(function(a, b){
|
|
2739
|
+
return a[1] - b[1];
|
|
2740
|
+
});
|
|
2741
|
+
return ret[0][0] * Math[n](t / ret[0][0]);
|
|
2742
|
+
});
|
|
2743
|
+
delta = ext[1] - ext[0];
|
|
2744
|
+
for (i$ = 1; i$ <= len; ++i$) {
|
|
2745
|
+
i = i$;
|
|
2746
|
+
g = +(delta * (Math.pow(i / len, pow) - Math.pow((i - 1) / len, pow))).toFixed(2);
|
|
2747
|
+
s = Math.floor(Math.log(g) / Math.LN10);
|
|
2748
|
+
for (j$ = 0, len$ = gaps.length; j$ < len$; ++j$) {
|
|
2749
|
+
j = gaps[j$];
|
|
2750
|
+
if ((step = +(j * Math.pow(10, s - 1).toFixed(2))) >= g) {
|
|
2751
|
+
break;
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
steps.push(step);
|
|
2755
|
+
}
|
|
2756
|
+
delta = steps.reduce(function(a, b){
|
|
2757
|
+
return a + b;
|
|
2758
|
+
}, 0);
|
|
2759
|
+
ext = [ext[0], (ref$ = ext[0] + delta) > (ref1$ = ext[1]) ? ref$ : ref1$];
|
|
2760
|
+
ext = [[ext[0], 'floor'], [ext[1], 'ceil']].map(function(arg$){
|
|
2761
|
+
var t, n, ret;
|
|
2762
|
+
t = arg$[0], n = arg$[1];
|
|
2763
|
+
ret = gaps.map(function(d){
|
|
2764
|
+
return [d, Math.abs(t - Math[n](t / d) * d)];
|
|
2765
|
+
});
|
|
2766
|
+
ret.sort(function(a, b){
|
|
2767
|
+
return a[1] - b[1];
|
|
2768
|
+
});
|
|
2769
|
+
return ret[0][0] * Math[n](t / ret[0][0]);
|
|
2770
|
+
});
|
|
2771
|
+
v = ext[0];
|
|
2772
|
+
for (i$ = 0; i$ < len; ++i$) {
|
|
2773
|
+
i = i$;
|
|
2774
|
+
ticks.push(v);
|
|
2775
|
+
v = v + steps[i];
|
|
2776
|
+
if (v >= o_ext[1]) {
|
|
2777
|
+
break;
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
ticks.push(v);
|
|
2781
|
+
}
|
|
2782
|
+
ticks.sort(function(a, b){
|
|
2783
|
+
return a - b;
|
|
2784
|
+
});
|
|
2785
|
+
extent = [ticks[0], ticks[len - 1]];
|
|
2786
|
+
} else if (o.pretty != null && !o.pretty) {
|
|
2787
|
+
ticks = (function(){
|
|
2788
|
+
var i$, to$, results$ = [];
|
|
2789
|
+
for (i$ = 0, to$ = len; i$ < to$; ++i$) {
|
|
2790
|
+
results$.push(i$);
|
|
2791
|
+
}
|
|
2792
|
+
return results$;
|
|
2793
|
+
}()).map(function(i){
|
|
2794
|
+
var ref$;
|
|
2795
|
+
return ext[0] + (ext[1] - ext[0]) * i / ((ref$ = len - 1) > 1 ? ref$ : 1);
|
|
2796
|
+
});
|
|
2797
|
+
extent = [ticks[0], ticks[len - 1]];
|
|
2798
|
+
} else {
|
|
2799
|
+
g = (ext[1] - ext[0]) / (len + 1);
|
|
2800
|
+
s = Math.floor(Math.log((ext[1] - ext[0] || 1) / (len + 1)) / Math.LN10);
|
|
2801
|
+
for (i$ = 0, len$ = (ref$ = [10, 20, 25, 50, 100]).length; i$ < len$; ++i$) {
|
|
2802
|
+
i = ref$[i$];
|
|
2803
|
+
if ((step = i * Math.pow(10, s - 1)) > g) {
|
|
2804
|
+
break;
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
base = step * Math.floor(ext[0] / step);
|
|
2808
|
+
ticks = (function(){
|
|
2809
|
+
var i$, to$, results$ = [];
|
|
2810
|
+
for (i$ = 0, to$ = len; i$ <= to$; ++i$) {
|
|
2811
|
+
results$.push(i$);
|
|
2812
|
+
}
|
|
2813
|
+
return results$;
|
|
2814
|
+
}()).map(function(i){
|
|
2815
|
+
return base + step * i;
|
|
2816
|
+
});
|
|
2817
|
+
extent = [ticks[0], ticks[len]];
|
|
2818
|
+
}
|
|
2819
|
+
if (lg = o.legend) {
|
|
2820
|
+
fmt = lg.format || function(it){
|
|
2821
|
+
return it;
|
|
2822
|
+
};
|
|
2823
|
+
unit = lg.unit || '';
|
|
2824
|
+
if (lg.range) {
|
|
2825
|
+
labels = [];
|
|
2826
|
+
for (i$ = 0, to$ = ticks.length - 1; i$ < to$; ++i$) {
|
|
2827
|
+
i = i$;
|
|
2828
|
+
ref$ = [ticks[i], ticks[i + 1]], t1 = ref$[0], t2 = ref$[1];
|
|
2829
|
+
labels.push({
|
|
2830
|
+
ext: [t1, t2],
|
|
2831
|
+
key: (t1 + t2) / 2,
|
|
2832
|
+
text: lg.text
|
|
2833
|
+
? lg.text(t1, t2)
|
|
2834
|
+
: fmt(t1) + " - " + fmt(t2) + unit
|
|
2835
|
+
});
|
|
2836
|
+
}
|
|
2837
|
+
} else {
|
|
2838
|
+
labels = ticks.map(function(it){
|
|
2839
|
+
return {
|
|
2840
|
+
key: it,
|
|
2841
|
+
text: lg.text
|
|
2842
|
+
? lg.text(it)
|
|
2843
|
+
: fmt(it) + "" + unit
|
|
2844
|
+
};
|
|
2845
|
+
});
|
|
2846
|
+
}
|
|
2847
|
+
labels.sort(function(a, b){
|
|
2848
|
+
if (a.key < b.key) {
|
|
2849
|
+
return 1;
|
|
2850
|
+
} else if (a.key > b.key) {
|
|
2851
|
+
return -1;
|
|
2852
|
+
} else {
|
|
2853
|
+
return 0;
|
|
2854
|
+
}
|
|
2855
|
+
});
|
|
2856
|
+
}
|
|
2857
|
+
return {
|
|
2858
|
+
ticks: ticks,
|
|
2859
|
+
extent: extent,
|
|
2860
|
+
labels: labels
|
|
2861
|
+
};
|
|
2862
|
+
};
|
|
2863
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
2864
|
+
(chart.utils || (chart.utils = {})).tick = tick;
|
|
2865
|
+
}
|
|
2866
|
+
}).call(this);
|
|
2867
|
+
(function(){
|
|
2868
|
+
var font, config;
|
|
2869
|
+
font = {
|
|
2870
|
+
family: {
|
|
2871
|
+
type: 'font'
|
|
2872
|
+
},
|
|
2873
|
+
size: {
|
|
2874
|
+
type: 'quantity',
|
|
2875
|
+
'default': '1em',
|
|
2876
|
+
units: [
|
|
2877
|
+
{
|
|
2878
|
+
name: 'em',
|
|
2879
|
+
max: 10,
|
|
2880
|
+
step: 0.01,
|
|
2881
|
+
'default': 1
|
|
2882
|
+
}, {
|
|
2883
|
+
name: 'px',
|
|
2884
|
+
max: 256,
|
|
2885
|
+
step: 1,
|
|
2886
|
+
'default': 16
|
|
2887
|
+
}
|
|
2888
|
+
]
|
|
2889
|
+
}
|
|
2890
|
+
};
|
|
2891
|
+
config = {
|
|
2892
|
+
from: function(c){
|
|
2893
|
+
var ret, _, this$ = this;
|
|
2894
|
+
ret = {};
|
|
2895
|
+
_ = function(o, c){
|
|
2896
|
+
var k, v;
|
|
2897
|
+
if (c.preset) {
|
|
2898
|
+
import$(o, JSON.parse(JSON.stringify(this$.preset[c.preset])));
|
|
2899
|
+
}
|
|
2900
|
+
for (k in c) {
|
|
2901
|
+
v = c[k];
|
|
2902
|
+
if (k === 'preset') {
|
|
2903
|
+
continue;
|
|
2904
|
+
}
|
|
2905
|
+
if (typeof v === 'string') {
|
|
2906
|
+
o[k] = JSON.parse(JSON.stringify(this$.preset[v])) || {};
|
|
2907
|
+
} else {
|
|
2908
|
+
_(o[k] || (o[k] = {}), v);
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
return o;
|
|
2912
|
+
};
|
|
2913
|
+
return _(ret, c);
|
|
2914
|
+
},
|
|
2915
|
+
preset: {
|
|
2916
|
+
'default': {
|
|
2917
|
+
margin: {
|
|
2918
|
+
type: 'number'
|
|
2919
|
+
},
|
|
2920
|
+
font: font,
|
|
2921
|
+
color: {
|
|
2922
|
+
type: 'color',
|
|
2923
|
+
'default': 'currentColor'
|
|
2924
|
+
},
|
|
2925
|
+
palette: {
|
|
2926
|
+
type: 'palette'
|
|
2927
|
+
},
|
|
2928
|
+
background: {
|
|
2929
|
+
type: 'color',
|
|
2930
|
+
'default': 'transparent'
|
|
2931
|
+
}
|
|
2932
|
+
},
|
|
2933
|
+
font: font,
|
|
2934
|
+
tip: {
|
|
2935
|
+
enabled: {
|
|
2936
|
+
type: 'boolean',
|
|
2937
|
+
'default': true
|
|
2938
|
+
},
|
|
2939
|
+
format: {
|
|
2940
|
+
type: 'format',
|
|
2941
|
+
'default': '.3s'
|
|
2942
|
+
}
|
|
2943
|
+
},
|
|
2944
|
+
label: {
|
|
2945
|
+
format: {
|
|
2946
|
+
type: 'format',
|
|
2947
|
+
'default': '.3s'
|
|
2948
|
+
}
|
|
2949
|
+
},
|
|
2950
|
+
legend: {
|
|
2951
|
+
selectable: {
|
|
2952
|
+
type: 'boolean',
|
|
2953
|
+
'default': true
|
|
2954
|
+
},
|
|
2955
|
+
enabled: {
|
|
2956
|
+
type: 'boolean',
|
|
2957
|
+
'default': true
|
|
2958
|
+
},
|
|
2959
|
+
position: {
|
|
2960
|
+
type: 'choice',
|
|
2961
|
+
values: ['bottom', 'right'],
|
|
2962
|
+
'default': 'right'
|
|
2963
|
+
},
|
|
2964
|
+
sort: {
|
|
2965
|
+
direction: {
|
|
2966
|
+
type: 'choice',
|
|
2967
|
+
values: ['asc', 'desc'],
|
|
2968
|
+
'default': 'desc'
|
|
2969
|
+
},
|
|
2970
|
+
mode: {
|
|
2971
|
+
type: 'choice',
|
|
2972
|
+
values: ['label', 'value', 'none'],
|
|
2973
|
+
'default': 'value'
|
|
2974
|
+
}
|
|
2975
|
+
},
|
|
2976
|
+
subset: {
|
|
2977
|
+
mode: {
|
|
2978
|
+
type: 'choice',
|
|
2979
|
+
values: ['shrink', 'dim', 'partial'],
|
|
2980
|
+
'default': 'shrink'
|
|
2981
|
+
},
|
|
2982
|
+
opacity: {
|
|
2983
|
+
type: 'number',
|
|
2984
|
+
'default': 0.2,
|
|
2985
|
+
min: 0,
|
|
2986
|
+
max: 1,
|
|
2987
|
+
step: 0.05
|
|
2988
|
+
}
|
|
2989
|
+
},
|
|
2990
|
+
crossfilter: {
|
|
2991
|
+
type: 'boolean',
|
|
2992
|
+
'default': false
|
|
2993
|
+
}
|
|
2994
|
+
},
|
|
2995
|
+
axis: {
|
|
2996
|
+
enabled: {
|
|
2997
|
+
type: 'boolean',
|
|
2998
|
+
'default': true
|
|
2999
|
+
},
|
|
3000
|
+
center: {
|
|
3001
|
+
type: 'boolean',
|
|
3002
|
+
'default': false
|
|
3003
|
+
},
|
|
3004
|
+
tick: {
|
|
3005
|
+
inner: {
|
|
3006
|
+
type: 'number',
|
|
3007
|
+
name: "Inner Tick Size",
|
|
3008
|
+
'default': 8,
|
|
3009
|
+
min: 0,
|
|
3010
|
+
max: 40,
|
|
3011
|
+
step: 0.1
|
|
3012
|
+
},
|
|
3013
|
+
color: {
|
|
3014
|
+
type: 'color',
|
|
3015
|
+
'default': 'currentColor'
|
|
3016
|
+
},
|
|
3017
|
+
count: {
|
|
3018
|
+
type: 'number',
|
|
3019
|
+
'default': 4,
|
|
3020
|
+
min: 1,
|
|
3021
|
+
max: 40
|
|
3022
|
+
},
|
|
3023
|
+
boundaryOffset: {
|
|
3024
|
+
type: 'boolean',
|
|
3025
|
+
'default': true
|
|
3026
|
+
}
|
|
3027
|
+
},
|
|
3028
|
+
baseline: {
|
|
3029
|
+
show: {
|
|
3030
|
+
type: 'boolean',
|
|
3031
|
+
'default': true
|
|
3032
|
+
},
|
|
3033
|
+
color: {
|
|
3034
|
+
type: 'color',
|
|
3035
|
+
'default': 'currentColor'
|
|
3036
|
+
}
|
|
3037
|
+
},
|
|
3038
|
+
label: {
|
|
3039
|
+
color: {
|
|
3040
|
+
type: 'color',
|
|
3041
|
+
'default': 'currentColor'
|
|
3042
|
+
},
|
|
3043
|
+
format: {
|
|
3044
|
+
type: 'format',
|
|
3045
|
+
'default': '.3s'
|
|
3046
|
+
},
|
|
3047
|
+
direction: {
|
|
3048
|
+
type: 'choice',
|
|
3049
|
+
'default': 'horizontal',
|
|
3050
|
+
values: ['horizontal', 'vertical']
|
|
3051
|
+
},
|
|
3052
|
+
gap: {
|
|
3053
|
+
type: 'number',
|
|
3054
|
+
'default': 1.5,
|
|
3055
|
+
min: 0,
|
|
3056
|
+
max: 10,
|
|
3057
|
+
step: 0.1
|
|
3058
|
+
},
|
|
3059
|
+
strategy: {
|
|
3060
|
+
type: 'choice',
|
|
3061
|
+
'default': 'stride',
|
|
3062
|
+
values: ['stride', 'ends']
|
|
3063
|
+
},
|
|
3064
|
+
tolerance: {
|
|
3065
|
+
type: 'number',
|
|
3066
|
+
'default': 0.2,
|
|
3067
|
+
min: 0,
|
|
3068
|
+
max: 1,
|
|
3069
|
+
step: 0.05
|
|
3070
|
+
},
|
|
3071
|
+
padding: {
|
|
3072
|
+
type: 'number',
|
|
3073
|
+
'default': 1,
|
|
3074
|
+
min: 0,
|
|
3075
|
+
max: 100,
|
|
3076
|
+
step: 0.5
|
|
3077
|
+
},
|
|
3078
|
+
font: font
|
|
3079
|
+
},
|
|
3080
|
+
caption: {
|
|
3081
|
+
color: {
|
|
3082
|
+
type: 'color',
|
|
3083
|
+
'default': 'currentColor'
|
|
3084
|
+
},
|
|
3085
|
+
text: {
|
|
3086
|
+
type: 'text',
|
|
3087
|
+
'default': ''
|
|
3088
|
+
},
|
|
3089
|
+
show: {
|
|
3090
|
+
type: 'boolean',
|
|
3091
|
+
'default': true
|
|
3092
|
+
},
|
|
3093
|
+
padding: {
|
|
3094
|
+
type: 'number',
|
|
3095
|
+
'default': 1,
|
|
3096
|
+
min: 0,
|
|
3097
|
+
max: 100,
|
|
3098
|
+
step: 0.5
|
|
3099
|
+
},
|
|
3100
|
+
position: {
|
|
3101
|
+
type: 'choice',
|
|
3102
|
+
'default': 4,
|
|
3103
|
+
values: [
|
|
3104
|
+
{
|
|
3105
|
+
name: 'in / start',
|
|
3106
|
+
value: 0
|
|
3107
|
+
}, {
|
|
3108
|
+
name: 'in / middle',
|
|
3109
|
+
value: 1
|
|
3110
|
+
}, {
|
|
3111
|
+
name: 'in / end',
|
|
3112
|
+
value: 2
|
|
3113
|
+
}, {
|
|
3114
|
+
name: 'out / start',
|
|
3115
|
+
value: 3
|
|
3116
|
+
}, {
|
|
3117
|
+
name: 'out / middle',
|
|
3118
|
+
value: 4
|
|
3119
|
+
}, {
|
|
3120
|
+
name: 'out / end',
|
|
3121
|
+
value: 5
|
|
3122
|
+
}
|
|
3123
|
+
]
|
|
3124
|
+
},
|
|
3125
|
+
font: font
|
|
3126
|
+
},
|
|
3127
|
+
sideNoteStart: {
|
|
3128
|
+
show: {
|
|
3129
|
+
type: 'boolean',
|
|
3130
|
+
'default': false
|
|
3131
|
+
},
|
|
3132
|
+
text: {
|
|
3133
|
+
type: 'text',
|
|
3134
|
+
'default': ''
|
|
3135
|
+
},
|
|
3136
|
+
position: {
|
|
3137
|
+
type: 'choice',
|
|
3138
|
+
'default': 0,
|
|
3139
|
+
values: [
|
|
3140
|
+
{
|
|
3141
|
+
name: 'in',
|
|
3142
|
+
value: 0
|
|
3143
|
+
}, {
|
|
3144
|
+
name: 'out',
|
|
3145
|
+
value: 1
|
|
3146
|
+
}
|
|
3147
|
+
]
|
|
3148
|
+
},
|
|
3149
|
+
font: font,
|
|
3150
|
+
color: {
|
|
3151
|
+
type: 'color',
|
|
3152
|
+
'default': 'currentColor'
|
|
3153
|
+
},
|
|
3154
|
+
padding: {
|
|
3155
|
+
type: 'number',
|
|
3156
|
+
'default': 1,
|
|
3157
|
+
min: 0,
|
|
3158
|
+
max: 100,
|
|
3159
|
+
step: 0.5
|
|
3160
|
+
}
|
|
3161
|
+
},
|
|
3162
|
+
sideNoteEnd: {
|
|
3163
|
+
show: {
|
|
3164
|
+
type: 'boolean',
|
|
3165
|
+
'default': false
|
|
3166
|
+
},
|
|
3167
|
+
text: {
|
|
3168
|
+
type: 'text',
|
|
3169
|
+
'default': ''
|
|
3170
|
+
},
|
|
3171
|
+
position: {
|
|
3172
|
+
type: 'choice',
|
|
3173
|
+
'default': 0,
|
|
3174
|
+
values: [
|
|
3175
|
+
{
|
|
3176
|
+
name: 'in',
|
|
3177
|
+
value: 0
|
|
3178
|
+
}, {
|
|
3179
|
+
name: 'out',
|
|
3180
|
+
value: 1
|
|
3181
|
+
}
|
|
3182
|
+
]
|
|
3183
|
+
},
|
|
3184
|
+
font: font,
|
|
3185
|
+
color: {
|
|
3186
|
+
type: 'color',
|
|
3187
|
+
'default': 'currentColor'
|
|
3188
|
+
},
|
|
3189
|
+
padding: {
|
|
3190
|
+
type: 'number',
|
|
3191
|
+
'default': 1,
|
|
3192
|
+
min: 0,
|
|
3193
|
+
max: 100,
|
|
3194
|
+
step: 0.5
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
};
|
|
3200
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
3201
|
+
(chart.utils || (chart.utils = {})).config = config;
|
|
3202
|
+
}
|
|
3203
|
+
function import$(obj, src){
|
|
3204
|
+
var own = {}.hasOwnProperty;
|
|
3205
|
+
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
|
3206
|
+
return obj;
|
|
3207
|
+
}
|
|
3208
|
+
}).call(this);
|
|
3209
|
+
(function(){
|
|
3210
|
+
var main;
|
|
3211
|
+
main = {
|
|
3212
|
+
number: function(opt){
|
|
3213
|
+
var data, len;
|
|
3214
|
+
opt == null && (opt = {});
|
|
3215
|
+
data = opt.data.filter(function(it){
|
|
3216
|
+
return !(!it || (it + "").trim() === '');
|
|
3217
|
+
});
|
|
3218
|
+
len = data.filter(function(it){
|
|
3219
|
+
return !isNaN(parseFloat(it));
|
|
3220
|
+
}).length;
|
|
3221
|
+
return len / data.length;
|
|
3222
|
+
},
|
|
3223
|
+
serial: function(opt){
|
|
3224
|
+
var data, hash, i$, to$, i, delta, k;
|
|
3225
|
+
opt == null && (opt = {});
|
|
3226
|
+
data = [].concat(opt.data);
|
|
3227
|
+
data.sort(function(a, b){
|
|
3228
|
+
return b - a;
|
|
3229
|
+
});
|
|
3230
|
+
hash = {};
|
|
3231
|
+
for (i$ = 1, to$ = data.length; i$ < to$; ++i$) {
|
|
3232
|
+
i = i$;
|
|
3233
|
+
if (isNaN(data[i]) || isNaN(data[i - 1])) {
|
|
3234
|
+
hash[data[i] > data[i - 1]
|
|
3235
|
+
? data[i] + ":" + data[i - 1]
|
|
3236
|
+
: data[i - 1] + ":" + data[i]] = true;
|
|
3237
|
+
} else {
|
|
3238
|
+
delta = data[i] - data[i - 1];
|
|
3239
|
+
}
|
|
3240
|
+
hash[delta] = true;
|
|
3241
|
+
}
|
|
3242
|
+
return 1 / ((function(){
|
|
3243
|
+
var results$ = [];
|
|
3244
|
+
for (k in hash) {
|
|
3245
|
+
results$.push(k);
|
|
3246
|
+
}
|
|
3247
|
+
return results$;
|
|
3248
|
+
}()).filter(function(it){
|
|
3249
|
+
return it !== '0';
|
|
3250
|
+
}).length || 2);
|
|
3251
|
+
},
|
|
3252
|
+
text: function(opt){
|
|
3253
|
+
opt == null && (opt = {});
|
|
3254
|
+
return 1 - this.number(opt);
|
|
3255
|
+
},
|
|
3256
|
+
category: function(opt){
|
|
3257
|
+
var len, maxlen, ret, ref$, ref1$, ref2$;
|
|
3258
|
+
opt == null && (opt = {});
|
|
3259
|
+
len = Array.from(new Set(opt.data)).length;
|
|
3260
|
+
maxlen = opt.data.length;
|
|
3261
|
+
ret = (ref$ = (ref1$ = 1 - ((ref2$ = len - 2) > 0 ? ref2$ : 0) / maxlen - 1 / maxlen) > 0 ? ref1$ : 0) < 1 ? ref$ : 1;
|
|
3262
|
+
if (this.number(opt)) {
|
|
3263
|
+
ret = ret * 0.9;
|
|
3264
|
+
}
|
|
3265
|
+
return ret;
|
|
3266
|
+
},
|
|
3267
|
+
parse: function(data){
|
|
3268
|
+
var head, body;
|
|
3269
|
+
if (Array.isArray(data)) {
|
|
3270
|
+
head = data.slice(0, 1)[0];
|
|
3271
|
+
body = data.slice(1);
|
|
3272
|
+
body = body.map(function(d, i){
|
|
3273
|
+
var ret;
|
|
3274
|
+
ret = {};
|
|
3275
|
+
head.map(function(h, j){
|
|
3276
|
+
return ret[h] = d[j];
|
|
3277
|
+
});
|
|
3278
|
+
return ret;
|
|
3279
|
+
});
|
|
3280
|
+
return {
|
|
3281
|
+
head: head,
|
|
3282
|
+
body: body
|
|
3283
|
+
};
|
|
3284
|
+
}
|
|
3285
|
+
return data;
|
|
3286
|
+
},
|
|
3287
|
+
autotype: function(data){
|
|
3288
|
+
var head, res$, k, type, i$, len$, key, d, ret, list;
|
|
3289
|
+
data == null && (data = []);
|
|
3290
|
+
res$ = [];
|
|
3291
|
+
for (k in data[0] || {}) {
|
|
3292
|
+
res$.push(k);
|
|
3293
|
+
}
|
|
3294
|
+
head = res$;
|
|
3295
|
+
type = [];
|
|
3296
|
+
for (i$ = 0, len$ = head.length; i$ < len$; ++i$) {
|
|
3297
|
+
key = head[i$];
|
|
3298
|
+
d = data.map(fn$);
|
|
3299
|
+
ret = {
|
|
3300
|
+
key: key,
|
|
3301
|
+
types: {
|
|
3302
|
+
R: main.number({
|
|
3303
|
+
data: d
|
|
3304
|
+
}),
|
|
3305
|
+
O: main.serial({
|
|
3306
|
+
data: d
|
|
3307
|
+
}),
|
|
3308
|
+
N: main.text({
|
|
3309
|
+
data: d
|
|
3310
|
+
}),
|
|
3311
|
+
C: main.category({
|
|
3312
|
+
data: d
|
|
3313
|
+
})
|
|
3314
|
+
}
|
|
3315
|
+
};
|
|
3316
|
+
list = ['R', 'O', 'N', 'C'].map(fn1$);
|
|
3317
|
+
list.sort(fn2$);
|
|
3318
|
+
ret.type = list[0][0];
|
|
3319
|
+
type.push(ret);
|
|
3320
|
+
}
|
|
3321
|
+
return type;
|
|
3322
|
+
function fn$(it){
|
|
3323
|
+
return it[key];
|
|
3324
|
+
}
|
|
3325
|
+
function fn1$(it){
|
|
3326
|
+
return [it, ret.types[it]];
|
|
3327
|
+
}
|
|
3328
|
+
function fn2$(a, b){
|
|
3329
|
+
return b[1] - a[1];
|
|
3330
|
+
}
|
|
3331
|
+
},
|
|
3332
|
+
autobind: function(data, dimension){
|
|
3333
|
+
var datatypes, dims, k, v, i$, len$, dim, ts, j$, to$, i, t, k$, to1$, dt, ret;
|
|
3334
|
+
data == null && (data = []);
|
|
3335
|
+
dimension == null && (dimension = {});
|
|
3336
|
+
datatypes = this.autotype(data);
|
|
3337
|
+
dims = (function(){
|
|
3338
|
+
var ref$, results$ = [];
|
|
3339
|
+
for (k in ref$ = dimension) {
|
|
3340
|
+
v = ref$[k];
|
|
3341
|
+
results$.push({
|
|
3342
|
+
k: k,
|
|
3343
|
+
v: v
|
|
3344
|
+
});
|
|
3345
|
+
}
|
|
3346
|
+
return results$;
|
|
3347
|
+
}()).filter(function(it){
|
|
3348
|
+
return !it.v.passive;
|
|
3349
|
+
});
|
|
3350
|
+
dims.sort(function(a, b){
|
|
3351
|
+
var ret, ref$, ma, mb;
|
|
3352
|
+
ret = (a.v.priority || 100) - (b.v.priority || 100);
|
|
3353
|
+
if (ret !== 0) {
|
|
3354
|
+
return ret;
|
|
3355
|
+
}
|
|
3356
|
+
ref$ = [a.v.type || 'R', b.v.type || 'R'].map(function(t){
|
|
3357
|
+
return Math.min.apply(Math, (function(){
|
|
3358
|
+
var i$, to$, results$ = [];
|
|
3359
|
+
for (i$ = 0, to$ = t.length; i$ < to$; ++i$) {
|
|
3360
|
+
results$.push(i$);
|
|
3361
|
+
}
|
|
3362
|
+
return results$;
|
|
3363
|
+
}()).map(function(i){
|
|
3364
|
+
return "CONR".indexOf(t[i]);
|
|
3365
|
+
}));
|
|
3366
|
+
}), ma = ref$[0], mb = ref$[1];
|
|
3367
|
+
return ma - mb;
|
|
3368
|
+
});
|
|
3369
|
+
for (i$ = 0, len$ = dims.length; i$ < len$; ++i$) {
|
|
3370
|
+
dim = dims[i$];
|
|
3371
|
+
dim.bind = null;
|
|
3372
|
+
ts = dim.v.type || 'RNOC';
|
|
3373
|
+
for (j$ = 0, to$ = ts.length; j$ < to$; ++j$) {
|
|
3374
|
+
i = j$;
|
|
3375
|
+
t = ts[i];
|
|
3376
|
+
datatypes.sort(fn$);
|
|
3377
|
+
for (k$ = 0, to1$ = datatypes.length; k$ < to1$; ++k$) {
|
|
3378
|
+
i = k$;
|
|
3379
|
+
dt = datatypes[i];
|
|
3380
|
+
if (dt.types[t] < 0.5 || dt.used || (t === 'C' && dt.types.R > 0.5)) {
|
|
3381
|
+
continue;
|
|
3382
|
+
}
|
|
3383
|
+
dim.bind = dim.v.multiple ? [dt] : dt;
|
|
3384
|
+
dt.used = true;
|
|
3385
|
+
break;
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
}
|
|
3389
|
+
for (i$ = 0, len$ = dims.length; i$ < len$; ++i$) {
|
|
3390
|
+
dim = dims[i$];
|
|
3391
|
+
if (!dim.v.multiple) {
|
|
3392
|
+
continue;
|
|
3393
|
+
}
|
|
3394
|
+
ts = dim.v.type || 'RNOC';
|
|
3395
|
+
for (j$ = 0, to$ = ts.length; j$ < to$; ++j$) {
|
|
3396
|
+
i = j$;
|
|
3397
|
+
t = ts[i];
|
|
3398
|
+
datatypes.sort(fn1$);
|
|
3399
|
+
for (k$ = 0, to1$ = datatypes.length; k$ < to1$; ++k$) {
|
|
3400
|
+
i = k$;
|
|
3401
|
+
dt = datatypes[i];
|
|
3402
|
+
if (dt.types[t] < 0.5 || dt.used || (t === 'C' && dt.types.R > 0.5)) {
|
|
3403
|
+
continue;
|
|
3404
|
+
}
|
|
3405
|
+
dim.bind.push(dt);
|
|
3406
|
+
dt.used = true;
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
ret = {};
|
|
3411
|
+
for (i$ = 0, len$ = dims.length; i$ < len$; ++i$) {
|
|
3412
|
+
dim = dims[i$];
|
|
3413
|
+
if (dim.bind) {
|
|
3414
|
+
ret[dim.k] = dim.bind;
|
|
3415
|
+
(Array.isArray(dim.bind)
|
|
3416
|
+
? dim.bind
|
|
3417
|
+
: [dim.bind]).map(fn2$);
|
|
3418
|
+
}
|
|
3419
|
+
}
|
|
3420
|
+
return ret;
|
|
3421
|
+
function fn$(a, b){
|
|
3422
|
+
var ret;
|
|
3423
|
+
ret = (b.types[t] || 0) - (a.types[t] || 0);
|
|
3424
|
+
if (b.types[t] === a.types[t] && t === 'R') {
|
|
3425
|
+
return (a.types.O || 0) - (b.types.O || 0);
|
|
3426
|
+
}
|
|
3427
|
+
return ret;
|
|
3428
|
+
}
|
|
3429
|
+
function fn1$(a, b){
|
|
3430
|
+
var ret;
|
|
3431
|
+
ret = (b[t] || 0) - (a[t] || 0);
|
|
3432
|
+
if (b[t] === a[t] && t === 'R') {
|
|
3433
|
+
return (a.O || 0) - (b.O || 0);
|
|
3434
|
+
}
|
|
3435
|
+
return ret;
|
|
3436
|
+
}
|
|
3437
|
+
function fn2$(it){
|
|
3438
|
+
var ref$;
|
|
3439
|
+
return ref$ = it.used, delete it.used, ref$;
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
};
|
|
3443
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
3444
|
+
(chart.utils || (chart.utils = {})).data = main;
|
|
3445
|
+
}
|
|
3446
|
+
}).call(this);
|
|
3447
|
+
(function(){
|
|
3448
|
+
var svgns, legend;
|
|
3449
|
+
svgns = "http://www.w3.org/2000/svg";
|
|
3450
|
+
legend = function(opt){
|
|
3451
|
+
var x$, nodeLayout, nodeRender, gl, gs, gt, add, lng, ref$, res, this$ = this;
|
|
3452
|
+
opt == null && (opt = {});
|
|
3453
|
+
this._data = opt.data || [];
|
|
3454
|
+
this.name = opt.name || 'legend';
|
|
3455
|
+
this.cfg = opt.cfg || {};
|
|
3456
|
+
this.root = typeof opt.root === 'string'
|
|
3457
|
+
? document.querySelector(opt.root)
|
|
3458
|
+
: opt.root;
|
|
3459
|
+
this.dir = opt.direction || 'vertical';
|
|
3460
|
+
this.evtHandler = {};
|
|
3461
|
+
this._picked = Object.fromEntries(this._data.map(function(it){
|
|
3462
|
+
return [it.key, true];
|
|
3463
|
+
}));
|
|
3464
|
+
this.layout = opt.layout || new layout({
|
|
3465
|
+
root: this.root
|
|
3466
|
+
});
|
|
3467
|
+
x$ = this.layout;
|
|
3468
|
+
x$.on('update', function(){
|
|
3469
|
+
return this$.update();
|
|
3470
|
+
});
|
|
3471
|
+
x$.on('render', function(){
|
|
3472
|
+
return this$.render();
|
|
3473
|
+
});
|
|
3474
|
+
this.id = Math.random().toString(36).substring(2);
|
|
3475
|
+
nodeLayout = this.layout.getNode(this.name);
|
|
3476
|
+
nodeRender = this.layout.getGroup(this.name);
|
|
3477
|
+
if (!nodeLayout.querySelector('[ld-each=legend]')) {
|
|
3478
|
+
nodeLayout.innerHTML = "<div class=\"pdlg " + this.dir + "\">\n <div ld-each=\"legend\">\n <div class=\"pdl-cell\" ld=\"shape\" data-only></div>\n <div class=\"pdl-cell\" ld=\"text\" data-only></div>\n </div>\n</div>";
|
|
3479
|
+
}
|
|
3480
|
+
if (!nodeRender.querySelector('[ld-each=legend]')) {
|
|
3481
|
+
gl = document.createElementNS(svgns, "g");
|
|
3482
|
+
gs = document.createElementNS(svgns, "g");
|
|
3483
|
+
gt = document.createElementNS(svgns, "g");
|
|
3484
|
+
gl.classList.add('pdlg-g');
|
|
3485
|
+
gl.setAttribute('ld-each', 'legend');
|
|
3486
|
+
gs.setAttribute('ld', 'shape');
|
|
3487
|
+
gt.setAttribute('ld', 'text');
|
|
3488
|
+
gl.appendChild(gs);
|
|
3489
|
+
gl.appendChild(gt);
|
|
3490
|
+
nodeRender.appendChild(gl);
|
|
3491
|
+
}
|
|
3492
|
+
this._i18n = opt.i18n || ((typeof block != 'undefined' && block !== null) && block.i18n && block.i18n.module ? block.i18n.module : null);
|
|
3493
|
+
this._t = opt.t || null;
|
|
3494
|
+
if (this._i18n) {
|
|
3495
|
+
if (add = this._i18n.addResourceBundle) {
|
|
3496
|
+
for (lng in ref$ = legend.i18n) {
|
|
3497
|
+
res = ref$[lng];
|
|
3498
|
+
try {
|
|
3499
|
+
add.call(this._i18n, lng, legend.i18nNs, res, true, false);
|
|
3500
|
+
} catch (e$) {}
|
|
3501
|
+
}
|
|
3502
|
+
}
|
|
3503
|
+
if (this._i18n.on) {
|
|
3504
|
+
this._i18n.on('languageChanged', this._lngHandler = function(){
|
|
3505
|
+
return this$._relocalize();
|
|
3506
|
+
});
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
this._func = [
|
|
3510
|
+
{
|
|
3511
|
+
key: "all",
|
|
3512
|
+
type: "func",
|
|
3513
|
+
text: this._text('all')
|
|
3514
|
+
}, {
|
|
3515
|
+
key: "none",
|
|
3516
|
+
type: "func",
|
|
3517
|
+
text: this._text('none')
|
|
3518
|
+
}
|
|
3519
|
+
];
|
|
3520
|
+
this.view = {
|
|
3521
|
+
layout: new ldview({
|
|
3522
|
+
root: this.layout.getNode(this.name),
|
|
3523
|
+
initRender: false,
|
|
3524
|
+
handler: {
|
|
3525
|
+
legend: {
|
|
3526
|
+
list: function(){
|
|
3527
|
+
var ret, opt, dir;
|
|
3528
|
+
ret = this$._data.map(function(it){
|
|
3529
|
+
return it;
|
|
3530
|
+
});
|
|
3531
|
+
opt = this$.cfg.sort || {};
|
|
3532
|
+
if (opt.mode !== 'none') {
|
|
3533
|
+
dir = opt.direction === 'desc'
|
|
3534
|
+
? 1
|
|
3535
|
+
: -1;
|
|
3536
|
+
ret.sort(function(a, b){
|
|
3537
|
+
return opt.mode === 'value'
|
|
3538
|
+
? dir * (b.value - a.value)
|
|
3539
|
+
: dir * (a.text < b.text
|
|
3540
|
+
? 1
|
|
3541
|
+
: a.text > b.text ? -1 : 0);
|
|
3542
|
+
});
|
|
3543
|
+
}
|
|
3544
|
+
return ret.concat(this$.cfg.selectable
|
|
3545
|
+
? this$._func
|
|
3546
|
+
: []);
|
|
3547
|
+
},
|
|
3548
|
+
key: function(it){
|
|
3549
|
+
return it.key;
|
|
3550
|
+
},
|
|
3551
|
+
view: {
|
|
3552
|
+
handler: {
|
|
3553
|
+
shape: function(arg$){
|
|
3554
|
+
var node, ctx;
|
|
3555
|
+
node = arg$.node, ctx = arg$.ctx;
|
|
3556
|
+
return node.setAttribute('data-name', this$._name(ctx, "shape"));
|
|
3557
|
+
},
|
|
3558
|
+
text: function(arg$){
|
|
3559
|
+
var node, ctx;
|
|
3560
|
+
node = arg$.node, ctx = arg$.ctx;
|
|
3561
|
+
node.setAttribute('data-name', this$._name(ctx, "text"));
|
|
3562
|
+
return node.innerText = ctx.text;
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
}),
|
|
3569
|
+
render: new ldview({
|
|
3570
|
+
root: this.layout.getGroup(this.name),
|
|
3571
|
+
initRender: false,
|
|
3572
|
+
handler: {
|
|
3573
|
+
legend: {
|
|
3574
|
+
list: function(){
|
|
3575
|
+
return this$._data.concat(this$.cfg.selectable
|
|
3576
|
+
? this$._func
|
|
3577
|
+
: []);
|
|
3578
|
+
},
|
|
3579
|
+
key: function(it){
|
|
3580
|
+
return it.key;
|
|
3581
|
+
},
|
|
3582
|
+
view: {
|
|
3583
|
+
action: {
|
|
3584
|
+
click: {
|
|
3585
|
+
"@": function(arg$){
|
|
3586
|
+
var node, ctx, k;
|
|
3587
|
+
node = arg$.node, ctx = arg$.ctx;
|
|
3588
|
+
if (!this$.cfg.selectable) {
|
|
3589
|
+
return;
|
|
3590
|
+
}
|
|
3591
|
+
if (ctx.type === 'func') {
|
|
3592
|
+
for (k in this$._picked) {
|
|
3593
|
+
this$._picked[k] = ctx.key === 'all' ? true : false;
|
|
3594
|
+
}
|
|
3595
|
+
} else {
|
|
3596
|
+
this$._picked[ctx.key] = !this$._picked[ctx.key];
|
|
3597
|
+
}
|
|
3598
|
+
this$.view.render.render('legend');
|
|
3599
|
+
return this$.fire('select', this$._picked);
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
},
|
|
3603
|
+
handler: {
|
|
3604
|
+
"@": function(arg$){
|
|
3605
|
+
var node, ctx;
|
|
3606
|
+
node = arg$.node, ctx = arg$.ctx;
|
|
3607
|
+
return node.style.opacity = !this$.cfg.selectable || ctx.type === 'func' || this$._picked[ctx.key] ? 1 : 0.3;
|
|
3608
|
+
},
|
|
3609
|
+
"shape": function(arg$){
|
|
3610
|
+
var node, ctx, n, box, rbox;
|
|
3611
|
+
node = arg$.node, ctx = arg$.ctx;
|
|
3612
|
+
if (ctx.type === 'func') {
|
|
3613
|
+
node.style.display = 'none';
|
|
3614
|
+
return;
|
|
3615
|
+
}
|
|
3616
|
+
if (!node.querySelector('circle')) {
|
|
3617
|
+
node.appendChild(document.createElementNS(svgns, 'circle'));
|
|
3618
|
+
}
|
|
3619
|
+
n = node.querySelector('circle');
|
|
3620
|
+
box = this$.layout.getBox(this$._name(ctx, 'shape'));
|
|
3621
|
+
rbox = this$.layout.getBox(this$.name);
|
|
3622
|
+
n.setAttribute('cx', ".5em");
|
|
3623
|
+
n.setAttribute('cy', ".5em");
|
|
3624
|
+
n.setAttribute('r', ".5em");
|
|
3625
|
+
n.setAttribute('transform', "translate(" + (box.x - rbox.x) + ", " + (box.y - rbox.y) + ")");
|
|
3626
|
+
if (typeof opt.shape === 'function') {
|
|
3627
|
+
return opt.shape.call(n, ctx);
|
|
3628
|
+
}
|
|
3629
|
+
},
|
|
3630
|
+
"text": function(arg$){
|
|
3631
|
+
var node, ctx, n, nbox, rbox, ret;
|
|
3632
|
+
node = arg$.node, ctx = arg$.ctx;
|
|
3633
|
+
n = this$.layout.getNode(this$._name(ctx, 'text'));
|
|
3634
|
+
nbox = this$.layout.getBox(this$._name(ctx, 'text'));
|
|
3635
|
+
rbox = this$.layout.getBox(this$.name);
|
|
3636
|
+
node.setAttribute('transform', "translate(" + (nbox.x - rbox.x) + ", " + (nbox.y - rbox.y) + ")");
|
|
3637
|
+
node.textContent = "";
|
|
3638
|
+
ret = wrapSvgText({
|
|
3639
|
+
node: n,
|
|
3640
|
+
useRange: true
|
|
3641
|
+
});
|
|
3642
|
+
return node.appendChild(ret);
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3648
|
+
})
|
|
3649
|
+
};
|
|
3650
|
+
this.update();
|
|
3651
|
+
return this;
|
|
3652
|
+
};
|
|
3653
|
+
legend.i18nNs = "@plotdb/chart.legend";
|
|
3654
|
+
legend.i18n = {
|
|
3655
|
+
en: {
|
|
3656
|
+
all: "Select All",
|
|
3657
|
+
none: "Select None"
|
|
3658
|
+
},
|
|
3659
|
+
"zh-TW": {
|
|
3660
|
+
all: "全選",
|
|
3661
|
+
none: "全不選"
|
|
3662
|
+
},
|
|
3663
|
+
"zh-CN": {
|
|
3664
|
+
all: "全选",
|
|
3665
|
+
none: "全不选"
|
|
3666
|
+
},
|
|
3667
|
+
ja: {
|
|
3668
|
+
all: "すべて選択",
|
|
3669
|
+
none: "すべて解除"
|
|
3670
|
+
}
|
|
3671
|
+
};
|
|
3672
|
+
legend.prototype = import$(Object.create(Object.prototype), {
|
|
3673
|
+
_text: function(key){
|
|
3674
|
+
var r, k, lng, res;
|
|
3675
|
+
if (this._t && (r = this._t("legend." + key)) && r !== "legend." + key) {
|
|
3676
|
+
return r;
|
|
3677
|
+
}
|
|
3678
|
+
k = legend.i18nNs + ":" + key;
|
|
3679
|
+
if (this._i18n && this._i18n.t && (r = this._i18n.t(k)) && r !== k && r !== key) {
|
|
3680
|
+
return r;
|
|
3681
|
+
}
|
|
3682
|
+
lng = this._i18n ? this._i18n.language || this._i18n.lng : null;
|
|
3683
|
+
lng = lng || (typeof document != 'undefined' && document !== null ? document.documentElement.lang : '') || 'en';
|
|
3684
|
+
res = legend.i18n[lng] || legend.i18n[lng.split('-')[0]] || (/^zh/i.exec(lng) ? legend.i18n[/cn|hans|sg/i.exec(lng) ? 'zh-CN' : 'zh-TW'] : void 8) || legend.i18n.en;
|
|
3685
|
+
return res[key];
|
|
3686
|
+
},
|
|
3687
|
+
_relocalize: function(){
|
|
3688
|
+
var this$ = this;
|
|
3689
|
+
this._func.map(function(f){
|
|
3690
|
+
return f.text = this$._text(f.key);
|
|
3691
|
+
});
|
|
3692
|
+
if (!this.cfg.selectable) {
|
|
3693
|
+
return;
|
|
3694
|
+
}
|
|
3695
|
+
this.view.layout.render('legend');
|
|
3696
|
+
this.layout.update(false);
|
|
3697
|
+
return this.view.render.render();
|
|
3698
|
+
},
|
|
3699
|
+
destroy: function(){
|
|
3700
|
+
if (this._i18n && this._lngHandler && this._i18n.off) {
|
|
3701
|
+
this._i18n.off('languageChanged', this._lngHandler);
|
|
3702
|
+
}
|
|
3703
|
+
return this._lngHandler = null;
|
|
3704
|
+
},
|
|
3705
|
+
_name: function(ctx, type){
|
|
3706
|
+
type == null && (type = "s");
|
|
3707
|
+
return "pdlg-" + type + "-" + this.id + "-" + (ctx.type || '') + "-" + ctx.key;
|
|
3708
|
+
},
|
|
3709
|
+
enabled: function(){
|
|
3710
|
+
return this._data && this._data.length && (!(this.cfg.enabled != null) || this.cfg.enabled);
|
|
3711
|
+
},
|
|
3712
|
+
update: function(){
|
|
3713
|
+
var val, ref$, node;
|
|
3714
|
+
val = this.enabled() ? '' : '0px';
|
|
3715
|
+
ref$ = this.layout.getNode(this.name).style;
|
|
3716
|
+
ref$.width = val;
|
|
3717
|
+
ref$.height = val;
|
|
3718
|
+
ref$.padding = val;
|
|
3719
|
+
ref$.margin = val;
|
|
3720
|
+
node = this.layout.getNode(this.name).querySelector('.pdlg');
|
|
3721
|
+
if (node) {
|
|
3722
|
+
if (this.dir === 'vertical') {
|
|
3723
|
+
node.style.height = 'fit-content';
|
|
3724
|
+
node.style.height = getComputedStyle(node.parentNode).height;
|
|
3725
|
+
} else {
|
|
3726
|
+
node.style.height = '';
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
return this.view.layout.render();
|
|
3730
|
+
},
|
|
3731
|
+
render: function(){
|
|
3732
|
+
var enabled, g;
|
|
3733
|
+
enabled = this.enabled();
|
|
3734
|
+
g = this.layout.getGroup(this.name);
|
|
3735
|
+
g.style.display = enabled ? '' : 'none';
|
|
3736
|
+
if (enabled) {
|
|
3737
|
+
return this.view.render.render();
|
|
3738
|
+
}
|
|
3739
|
+
},
|
|
3740
|
+
config: function(cfg){
|
|
3741
|
+
var node, this$ = this;
|
|
3742
|
+
if (!(cfg != null)) {
|
|
3743
|
+
return this.cfg;
|
|
3744
|
+
}
|
|
3745
|
+
if (this.cfg.selectable !== cfg.selectable) {
|
|
3746
|
+
this._picked = null;
|
|
3747
|
+
this._updatePicked();
|
|
3748
|
+
}
|
|
3749
|
+
this.cfg = cfg;
|
|
3750
|
+
this.dir = this.cfg.position === 'bottom' ? 'horizontal' : 'vertical';
|
|
3751
|
+
node = this.layout.getNode(this.name).querySelector('.pdlg');
|
|
3752
|
+
return ['horizontal', 'vertical'].map(function(it){
|
|
3753
|
+
return node.classList.toggle(it, this$.dir === it);
|
|
3754
|
+
});
|
|
3755
|
+
},
|
|
3756
|
+
_updatePicked: function(){
|
|
3757
|
+
var this$ = this;
|
|
3758
|
+
if (!(this._picked != null)) {
|
|
3759
|
+
this._picked = Object.fromEntries(this._data.map(function(d){
|
|
3760
|
+
return [d.key, true];
|
|
3761
|
+
}));
|
|
3762
|
+
}
|
|
3763
|
+
return this._data.map(function(d){
|
|
3764
|
+
if (!(this$._picked[d.key] != null)) {
|
|
3765
|
+
return this$._picked[d.key] = true;
|
|
3766
|
+
}
|
|
3767
|
+
});
|
|
3768
|
+
},
|
|
3769
|
+
data: function(data){
|
|
3770
|
+
var hash;
|
|
3771
|
+
if (!arguments.length) {
|
|
3772
|
+
return this._data;
|
|
3773
|
+
}
|
|
3774
|
+
hash = {};
|
|
3775
|
+
data.map(function(d, i){
|
|
3776
|
+
return hash[d.key] = i;
|
|
3777
|
+
});
|
|
3778
|
+
this._data = data.filter(function(d, i){
|
|
3779
|
+
return hash[d.key] === i;
|
|
3780
|
+
});
|
|
3781
|
+
this._range = this._data.filter(function(it){
|
|
3782
|
+
return it.ext;
|
|
3783
|
+
});
|
|
3784
|
+
this._updatePicked();
|
|
3785
|
+
this.update();
|
|
3786
|
+
this.layout.update(false);
|
|
3787
|
+
return this.view.render.render();
|
|
3788
|
+
},
|
|
3789
|
+
on: function(n, cb){
|
|
3790
|
+
var this$ = this;
|
|
3791
|
+
return (Array.isArray(n)
|
|
3792
|
+
? n
|
|
3793
|
+
: [n]).map(function(n){
|
|
3794
|
+
var ref$;
|
|
3795
|
+
return ((ref$ = this$.evtHandler)[n] || (ref$[n] = [])).push(cb);
|
|
3796
|
+
});
|
|
3797
|
+
},
|
|
3798
|
+
fire: function(n){
|
|
3799
|
+
var v, res$, i$, to$, ref$, len$, cb, results$ = [];
|
|
3800
|
+
res$ = [];
|
|
3801
|
+
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
|
|
3802
|
+
res$.push(arguments[i$]);
|
|
3803
|
+
}
|
|
3804
|
+
v = res$;
|
|
3805
|
+
for (i$ = 0, len$ = (ref$ = this.evtHandler[n] || []).length; i$ < len$; ++i$) {
|
|
3806
|
+
cb = ref$[i$];
|
|
3807
|
+
results$.push(cb.apply(this, v));
|
|
3808
|
+
}
|
|
3809
|
+
return results$;
|
|
3810
|
+
},
|
|
3811
|
+
isSelected: function(key){
|
|
3812
|
+
var this$ = this;
|
|
3813
|
+
if (!(this._range && this._range.length)) {
|
|
3814
|
+
return !!this._picked[key];
|
|
3815
|
+
}
|
|
3816
|
+
return !!this._range.filter(function(it){
|
|
3817
|
+
return key >= it.ext[0] && key < it.ext[1] && this$._picked[it.key];
|
|
3818
|
+
}).length;
|
|
3819
|
+
},
|
|
3820
|
+
mode: function(){
|
|
3821
|
+
if (((this.cfg.subset || {}).mode || 'shrink') === 'shrink') {
|
|
3822
|
+
return 'shrink';
|
|
3823
|
+
} else {
|
|
3824
|
+
return 'dim';
|
|
3825
|
+
}
|
|
3826
|
+
},
|
|
3827
|
+
opacity: function(){
|
|
3828
|
+
var ref$;
|
|
3829
|
+
return (ref$ = (this.cfg.subset || {}).opacity) != null ? ref$ : 0.2;
|
|
3830
|
+
},
|
|
3831
|
+
isVisible: function(key){
|
|
3832
|
+
return this.mode() !== 'shrink' || this.isSelected(key);
|
|
3833
|
+
},
|
|
3834
|
+
select: function(keys){
|
|
3835
|
+
var hash;
|
|
3836
|
+
if (!(keys != null)) {
|
|
3837
|
+
this._picked = Object.fromEntries(this._data.map(function(d){
|
|
3838
|
+
return [d.key, true];
|
|
3839
|
+
}));
|
|
3840
|
+
} else {
|
|
3841
|
+
hash = Object.fromEntries(keys.map(function(it){
|
|
3842
|
+
return [it, true];
|
|
3843
|
+
}));
|
|
3844
|
+
this._picked = Object.fromEntries(this._data.map(function(d){
|
|
3845
|
+
return [d.key, !!hash[d.key]];
|
|
3846
|
+
}));
|
|
3847
|
+
}
|
|
3848
|
+
this.view.render.render('legend');
|
|
3849
|
+
return this;
|
|
3850
|
+
},
|
|
3851
|
+
selected: function(){
|
|
3852
|
+
var ks, this$ = this;
|
|
3853
|
+
ks = this._data.filter(function(d){
|
|
3854
|
+
return !!this$._picked[d.key];
|
|
3855
|
+
}).map(function(d){
|
|
3856
|
+
return d.key;
|
|
3857
|
+
});
|
|
3858
|
+
if (ks.length === this._data.length) {
|
|
3859
|
+
return null;
|
|
3860
|
+
} else {
|
|
3861
|
+
return ks;
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3864
|
+
});
|
|
3865
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
3866
|
+
(chart.utils || (chart.utils = {})).legend = legend;
|
|
3867
|
+
}
|
|
3868
|
+
function import$(obj, src){
|
|
3869
|
+
var own = {}.hasOwnProperty;
|
|
3870
|
+
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
|
3871
|
+
return obj;
|
|
3872
|
+
}
|
|
3873
|
+
}).call(this);
|
|
3874
|
+
(function(){
|
|
3875
|
+
var ceNS, axis;
|
|
3876
|
+
ceNS = function(it){
|
|
3877
|
+
return document.createElementNS("http://www.w3.org/2000/svg", it);
|
|
3878
|
+
};
|
|
3879
|
+
axis = function(opt){
|
|
3880
|
+
var n, x$, y$, this$ = this;
|
|
3881
|
+
opt == null && (opt = {});
|
|
3882
|
+
this.dir = {
|
|
3883
|
+
"bottom": 0,
|
|
3884
|
+
"left": 2
|
|
3885
|
+
}[opt.direction || 'bottom'];
|
|
3886
|
+
this.name = opt.name || 'axis';
|
|
3887
|
+
this.layout = opt.layout || new layout({
|
|
3888
|
+
root: this.root
|
|
3889
|
+
});
|
|
3890
|
+
this._ticks = [];
|
|
3891
|
+
this._scale = opt.scale || function(it){
|
|
3892
|
+
return it;
|
|
3893
|
+
};
|
|
3894
|
+
this._format = chart.utils.format.simple;
|
|
3895
|
+
this._config(opt.cfg);
|
|
3896
|
+
this._map = {};
|
|
3897
|
+
this._n = n = {
|
|
3898
|
+
root: ceNS('g'),
|
|
3899
|
+
layout: this.layout.getNode(this.name),
|
|
3900
|
+
render: this.layout.getGroup(this.name),
|
|
3901
|
+
wrap: null,
|
|
3902
|
+
domain: ceNS('path')
|
|
3903
|
+
};
|
|
3904
|
+
n.render.appendChild(n.root);
|
|
3905
|
+
n.root.appendChild(n.domain);
|
|
3906
|
+
n.label = ceNS('text');
|
|
3907
|
+
n.label.textContent = '';
|
|
3908
|
+
x$ = n.label;
|
|
3909
|
+
x$.setAttribute('dominant-baseline', 'hanging');
|
|
3910
|
+
x$.setAttribute('text-anchor', 'middle');
|
|
3911
|
+
n.root.appendChild(n.label);
|
|
3912
|
+
n.sideNote = [0, 1].map(function(i){
|
|
3913
|
+
var ret, x$;
|
|
3914
|
+
ret = ceNS('text');
|
|
3915
|
+
ret.textContent = '';
|
|
3916
|
+
x$ = ret;
|
|
3917
|
+
x$.setAttribute('dominant-baseline', 'hanging');
|
|
3918
|
+
x$.setAttribute('text-anchor', ['start', 'end'][i]);
|
|
3919
|
+
return n.root.appendChild(ret);
|
|
3920
|
+
});
|
|
3921
|
+
this.wrapper();
|
|
3922
|
+
y$ = this.layout;
|
|
3923
|
+
y$.on('update', function(){
|
|
3924
|
+
return this$.update();
|
|
3925
|
+
});
|
|
3926
|
+
y$.on('render', function(){
|
|
3927
|
+
return this$.render();
|
|
3928
|
+
});
|
|
3929
|
+
return this;
|
|
3930
|
+
};
|
|
3931
|
+
axis.prototype = import$(Object.create(Object.prototype), {
|
|
3932
|
+
wrapper: function(){
|
|
3933
|
+
var n, ref$;
|
|
3934
|
+
n = this._n;
|
|
3935
|
+
if (n.wrap && n.wrap.parentNode) {
|
|
3936
|
+
n.wrap.parentNode.removeChild(n.wrap);
|
|
3937
|
+
}
|
|
3938
|
+
n.wrap = document.createElement('div');
|
|
3939
|
+
import$((ref$ = n.wrap.style, ref$.visibility = 'hidden', ref$.position = 'absolute', ref$.top = 0, ref$.left = 0, ref$.pointerEvents = 'none', ref$.userSelect = 'none', ref$.zIndex = 0, ref$.wordBreak = "break-all", ref$.lineHeight = '.95em', ref$), this.dir < 2 && this.cfg.textWidth != null
|
|
3940
|
+
? {
|
|
3941
|
+
whiteSpace: 'wrap',
|
|
3942
|
+
width: ((ref$ = this.cfg.textWidth) > 1 ? ref$ : 1) + "em"
|
|
3943
|
+
}
|
|
3944
|
+
: {
|
|
3945
|
+
whiteSpace: 'pre',
|
|
3946
|
+
width: '4em'
|
|
3947
|
+
});
|
|
3948
|
+
return n.layout.appendChild(n.wrap);
|
|
3949
|
+
},
|
|
3950
|
+
_config: function(c){
|
|
3951
|
+
var ref$, this$ = this;
|
|
3952
|
+
c == null && (c = {});
|
|
3953
|
+
this.cfg = {
|
|
3954
|
+
tick: {
|
|
3955
|
+
inner: 8
|
|
3956
|
+
},
|
|
3957
|
+
baseline: {},
|
|
3958
|
+
label: {
|
|
3959
|
+
padding: 1,
|
|
3960
|
+
direction: 'horizontal',
|
|
3961
|
+
gap: 1.5,
|
|
3962
|
+
strategy: 'stride',
|
|
3963
|
+
tolerance: 0.2
|
|
3964
|
+
},
|
|
3965
|
+
caption: {
|
|
3966
|
+
padding: 1
|
|
3967
|
+
},
|
|
3968
|
+
enabled: c.enabled,
|
|
3969
|
+
sideNoteStart: {
|
|
3970
|
+
padding: 1
|
|
3971
|
+
},
|
|
3972
|
+
sideNoteEnd: {
|
|
3973
|
+
padding: 1
|
|
3974
|
+
}
|
|
3975
|
+
};
|
|
3976
|
+
['tick', 'baseline', 'label', 'caption', 'sideNoteStart', 'sideNoteEnd'].map(function(n){
|
|
3977
|
+
return import$(this$.cfg[n], c[n] || {});
|
|
3978
|
+
});
|
|
3979
|
+
(ref$ = this.cfg.label).font || (ref$.font = {});
|
|
3980
|
+
(ref$ = this.cfg.caption).font || (ref$.font = {});
|
|
3981
|
+
(ref$ = this.cfg.sideNoteStart).font || (ref$.font = {});
|
|
3982
|
+
(ref$ = this.cfg.sideNoteEnd).font || (ref$.font = {});
|
|
3983
|
+
return this.format(this.cfg.label.format);
|
|
3984
|
+
},
|
|
3985
|
+
config: function(c){
|
|
3986
|
+
if (!(c != null)) {
|
|
3987
|
+
return this.cfg;
|
|
3988
|
+
}
|
|
3989
|
+
this._config(c);
|
|
3990
|
+
return this.wrapper();
|
|
3991
|
+
},
|
|
3992
|
+
format: function(f){
|
|
3993
|
+
if (!(f != null)) {
|
|
3994
|
+
return this._format;
|
|
3995
|
+
}
|
|
3996
|
+
return this._format = typeof f === 'string'
|
|
3997
|
+
? chart.utils.format.from(f)
|
|
3998
|
+
: f || chart.utils.format.simple;
|
|
3999
|
+
},
|
|
4000
|
+
scale: function(it){
|
|
4001
|
+
if (it != null) {
|
|
4002
|
+
return this._scale = it;
|
|
4003
|
+
} else {
|
|
4004
|
+
return this._scale;
|
|
4005
|
+
}
|
|
4006
|
+
},
|
|
4007
|
+
caption: function(it){
|
|
4008
|
+
if (arguments.length) {
|
|
4009
|
+
this._caption = it;
|
|
4010
|
+
}
|
|
4011
|
+
if (!this.cfg.enabled || (this.cfg.caption.show != null && !this.cfg.caption.show)) {
|
|
4012
|
+
return this._n.label.textContent = '';
|
|
4013
|
+
} else {
|
|
4014
|
+
return this._n.label.textContent = this.cfg.caption.text || this._caption || '';
|
|
4015
|
+
}
|
|
4016
|
+
},
|
|
4017
|
+
update: function(){},
|
|
4018
|
+
ticks: function(ticks){
|
|
4019
|
+
/* (v)alue -> (c)oordinate -> (t)ext -> (n)odes: { g(group), p(path), t(text) } */
|
|
4020
|
+
var map, size, unit, count, itr, ref$, ends, k, v, this$ = this;
|
|
4021
|
+
map = {};
|
|
4022
|
+
size = this._n.layout.getBoundingClientRect()[this.dir < 2 ? 'width' : 'height'];
|
|
4023
|
+
unit = this.dir < 2 && this.cfg.label.direction === 'vertical' ? 12 : 25;
|
|
4024
|
+
count = Math.round(size / unit);
|
|
4025
|
+
itr = (ref$ = Math.round(ticks.length / (count > 1 ? count : 1))) > 1 ? ref$ : 1;
|
|
4026
|
+
ends = this.cfg.label.strategy === 'ends';
|
|
4027
|
+
this._ticks = ticks.filter(function(d, i){
|
|
4028
|
+
return !(i % itr) || (ends && i === ticks.length - 1);
|
|
4029
|
+
}).map(function(o){
|
|
4030
|
+
var ref$, key$;
|
|
4031
|
+
if (typeof o !== 'object') {
|
|
4032
|
+
o = {
|
|
4033
|
+
v: o
|
|
4034
|
+
};
|
|
4035
|
+
}
|
|
4036
|
+
return map[o.v] = import$((ref$ = this$._map)[key$ = o.v] || (ref$[key$] = {}), o);
|
|
4037
|
+
});
|
|
4038
|
+
for (k in ref$ = this._map) {
|
|
4039
|
+
v = ref$[k];
|
|
4040
|
+
if (!map[k]) {
|
|
4041
|
+
v.n.g.parentNode.removeChild(v.n.g);
|
|
4042
|
+
}
|
|
4043
|
+
}
|
|
4044
|
+
this._map = map;
|
|
4045
|
+
return this._ticks.filter(function(o){
|
|
4046
|
+
return !o.n;
|
|
4047
|
+
}).map(function(o){
|
|
4048
|
+
o.n = {
|
|
4049
|
+
g: ceNS('g'),
|
|
4050
|
+
p: ceNS('path'),
|
|
4051
|
+
t: ceNS('g')
|
|
4052
|
+
};
|
|
4053
|
+
o.n.g.appendChild(o.n.p);
|
|
4054
|
+
o.n.g.appendChild(o.n.t);
|
|
4055
|
+
this$._n.root.appendChild(o.n.g);
|
|
4056
|
+
if (isNaN(+o.v)) {
|
|
4057
|
+
return o.t = o.v;
|
|
4058
|
+
}
|
|
4059
|
+
});
|
|
4060
|
+
},
|
|
4061
|
+
render: function(){
|
|
4062
|
+
var n, isHorizon, wrap, ticks, ref$, fontSize, box, mm3, md3, x$, yoff, this$ = this;
|
|
4063
|
+
n = this._n;
|
|
4064
|
+
isHorizon = this.dir < 2;
|
|
4065
|
+
wrap = n.wrap;
|
|
4066
|
+
wrap.style.fontSize = this.cfg.label.font.size ? this.cfg.label.font.size + "" || '' : void 8;
|
|
4067
|
+
wrap.setAttribute('class', (this.cfg.label.font.family || {}).className || '');
|
|
4068
|
+
ticks = this._ticks;
|
|
4069
|
+
if (this.cfg.enabled != null && !this.cfg.enabled) {
|
|
4070
|
+
if (isHorizon) {
|
|
4071
|
+
ref$ = n.layout.style;
|
|
4072
|
+
ref$.height = "0px";
|
|
4073
|
+
ref$.paddingTop = "0";
|
|
4074
|
+
ref$.paddingBottom = "0";
|
|
4075
|
+
} else {
|
|
4076
|
+
ref$ = n.layout.style;
|
|
4077
|
+
ref$.width = "0px";
|
|
4078
|
+
ref$.paddingLeft = "0";
|
|
4079
|
+
ref$.paddingRight = "0";
|
|
4080
|
+
}
|
|
4081
|
+
n.domain.style.display = 'none';
|
|
4082
|
+
ticks.map(function(o){
|
|
4083
|
+
return o.n.g.style.display = 'none';
|
|
4084
|
+
});
|
|
4085
|
+
return;
|
|
4086
|
+
} else {
|
|
4087
|
+
if (isHorizon) {
|
|
4088
|
+
ref$ = n.layout.style;
|
|
4089
|
+
ref$.height = "";
|
|
4090
|
+
ref$.paddingTop = "";
|
|
4091
|
+
ref$.paddingBottom = "";
|
|
4092
|
+
} else {
|
|
4093
|
+
ref$ = n.layout.style;
|
|
4094
|
+
ref$.width = "";
|
|
4095
|
+
ref$.paddingLeft = "";
|
|
4096
|
+
ref$.paddingRight = "";
|
|
4097
|
+
}
|
|
4098
|
+
n.domain.style.display = '';
|
|
4099
|
+
ticks.map(function(o){
|
|
4100
|
+
return o.n.g.style.display = '';
|
|
4101
|
+
});
|
|
4102
|
+
}
|
|
4103
|
+
fontSize = getComputedStyle(wrap).fontSize;
|
|
4104
|
+
box = n.layout.getBoundingClientRect();
|
|
4105
|
+
ref$ = n.domain.style;
|
|
4106
|
+
ref$.strokeWidth = 1;
|
|
4107
|
+
ref$.stroke = 'currentColor';
|
|
4108
|
+
ref$.fill = 'none';
|
|
4109
|
+
ticks.map(function(o, idx){
|
|
4110
|
+
var pos, ref$;
|
|
4111
|
+
pos = !idx
|
|
4112
|
+
? 0
|
|
4113
|
+
: idx === ticks.length - 1 ? 2 : 1;
|
|
4114
|
+
o._c = o.c != null
|
|
4115
|
+
? o.c
|
|
4116
|
+
: this$._scale(o.v) + (this$._scale.bandwidth ? this$._scale.bandwidth() / 2 : 0);
|
|
4117
|
+
o._t = o.t != null
|
|
4118
|
+
? o.t
|
|
4119
|
+
: this$._format(o.v);
|
|
4120
|
+
ref$ = o.n.p.style;
|
|
4121
|
+
ref$.strokeWidth = 1;
|
|
4122
|
+
ref$.stroke = 'currentColor';
|
|
4123
|
+
ref$.fill = 'none';
|
|
4124
|
+
wrap.textContent = o._t;
|
|
4125
|
+
wrap.style.textAlign = isHorizon
|
|
4126
|
+
? ['left', 'center', 'right'][pos]
|
|
4127
|
+
: ['right', 'left'][this$.dir - 2];
|
|
4128
|
+
o.n.tt = wrapSvgText({
|
|
4129
|
+
node: wrap
|
|
4130
|
+
});
|
|
4131
|
+
o.n.t.style.fontSize = fontSize;
|
|
4132
|
+
o.n.t.style.fill = this$.cfg.label.color;
|
|
4133
|
+
o.n.t.textContent = '';
|
|
4134
|
+
o.n.t.appendChild(o.n.tt);
|
|
4135
|
+
return o.n.t.setAttribute('class', (this$.cfg.label.font || {}).className || '');
|
|
4136
|
+
});
|
|
4137
|
+
ticks.sort(function(a, b){
|
|
4138
|
+
return a._c - b._c;
|
|
4139
|
+
});
|
|
4140
|
+
n.domain.style.stroke = this.cfg.baseline.show ? this.cfg.baseline.color : 'none';
|
|
4141
|
+
mm3 = (this.cfg.caption.position || 0) % 3;
|
|
4142
|
+
md3 = Math.floor((this.cfg.caption.position || 0) / 3);
|
|
4143
|
+
x$ = n.label;
|
|
4144
|
+
x$.setAttribute('text-anchor', ['start', 'middle', 'end'][mm3]);
|
|
4145
|
+
x$.setAttribute('dominant-baseline', ['baseline', 'hanging'][md3]);
|
|
4146
|
+
n.sideNote.map(function(n, i){
|
|
4147
|
+
var pos;
|
|
4148
|
+
pos = (this$.cfg[['sideNoteStart', 'sideNoteEnd'][i]] || {}).position || 0;
|
|
4149
|
+
return n.setAttribute('dominant-baseline', ['baseline', 'hanging'][pos]);
|
|
4150
|
+
});
|
|
4151
|
+
if (isHorizon) {
|
|
4152
|
+
n.domain.setAttribute('d', "M0 0L" + box.width + " 0Z");
|
|
4153
|
+
n.label.setAttribute('x', box.width / 2);
|
|
4154
|
+
n.label.setAttribute('x', [2, box.width / 2, box.width - 2][mm3]);
|
|
4155
|
+
} else {
|
|
4156
|
+
n.domain.setAttribute('d', "M0 0L0 " + box.height + "Z");
|
|
4157
|
+
yoff = [2, box.height / 2, box.height - 2][mm3];
|
|
4158
|
+
n.label.setAttribute("transform", "translate(0," + yoff + ") rotate(90)");
|
|
4159
|
+
}
|
|
4160
|
+
ticks.map(function(o){
|
|
4161
|
+
return o.box = o.n.t.getBBox();
|
|
4162
|
+
});
|
|
4163
|
+
return this.adjust();
|
|
4164
|
+
},
|
|
4165
|
+
adjust: function(){
|
|
4166
|
+
var ticks, isHorizon, vertical, em, place, gap, fits, sel, k, i, res$, i$, to$, tol, ref$, lo, hi, pick, even, p, idx, picked, shown, mm3, md3, size, delta, box, xoff, yoff, this$ = this;
|
|
4167
|
+
ticks = this._ticks;
|
|
4168
|
+
isHorizon = this.dir < 2;
|
|
4169
|
+
vertical = isHorizon && this.cfg.label.direction === 'vertical';
|
|
4170
|
+
em = parseFloat(getComputedStyle(this._n.wrap).fontSize) || 16;
|
|
4171
|
+
place = function(tick, idx){
|
|
4172
|
+
var pos, coord, box, offset, doOffset, r, toff;
|
|
4173
|
+
pos = !idx
|
|
4174
|
+
? 0
|
|
4175
|
+
: idx === ticks.length - 1 ? 2 : 1;
|
|
4176
|
+
coord = tick._c;
|
|
4177
|
+
box = tick.box;
|
|
4178
|
+
offset = {
|
|
4179
|
+
x: -box.x,
|
|
4180
|
+
y: -box.y
|
|
4181
|
+
};
|
|
4182
|
+
doOffset = this$._scale.bandwidth
|
|
4183
|
+
? false
|
|
4184
|
+
: this$.cfg.tick.boundaryOffset != null
|
|
4185
|
+
? !!this$.cfg.tick.boundaryOffset
|
|
4186
|
+
: this$.dir < 2 ? true : false;
|
|
4187
|
+
r = vertical
|
|
4188
|
+
? 1 / 2
|
|
4189
|
+
: doOffset
|
|
4190
|
+
? pos / 2
|
|
4191
|
+
: 1 / 2;
|
|
4192
|
+
if (vertical) {
|
|
4193
|
+
offset.x -= box.width;
|
|
4194
|
+
offset.y -= box.height * r;
|
|
4195
|
+
} else if (isHorizon) {
|
|
4196
|
+
offset.x -= box.width * r;
|
|
4197
|
+
} else {
|
|
4198
|
+
offset.y -= box.height * r;
|
|
4199
|
+
}
|
|
4200
|
+
tick.n.tt.setAttribute('transform', "translate(" + offset.x + "," + offset.y + ")");
|
|
4201
|
+
tick._size = vertical
|
|
4202
|
+
? box.height
|
|
4203
|
+
: box[isHorizon ? 'width' : 'height'];
|
|
4204
|
+
tick._sizeAlt = vertical
|
|
4205
|
+
? box.width
|
|
4206
|
+
: box[isHorizon ? 'height' : 'width'];
|
|
4207
|
+
tick._start = coord - tick._size * r;
|
|
4208
|
+
if (isHorizon) {
|
|
4209
|
+
tick.n.g.setAttribute('transform', "translate(" + coord + ",0)");
|
|
4210
|
+
tick.n.p.setAttribute('d', "M0 0L0 " + this$.cfg.tick.inner);
|
|
4211
|
+
toff = this$.cfg.tick.inner + this$.cfg.label.padding;
|
|
4212
|
+
tick.n.t.setAttribute('transform', ("translate(0," + toff + ")") + (vertical ? " rotate(-90)" : ""));
|
|
4213
|
+
} else {
|
|
4214
|
+
tick.n.g.setAttribute('transform', "translate(0," + coord + ")");
|
|
4215
|
+
tick.n.p.setAttribute('d', "M0 0L-" + this$.cfg.tick.inner + " 0");
|
|
4216
|
+
tick.n.t.setAttribute('transform', "translate(" + (-this$.cfg.tick.inner - tick._sizeAlt - 1 - this$.cfg.label.padding) + ",0)");
|
|
4217
|
+
}
|
|
4218
|
+
return tick.n.p.style.stroke = this$.cfg.tick.color || '';
|
|
4219
|
+
};
|
|
4220
|
+
ticks.map(place);
|
|
4221
|
+
gap = em * (this.cfg.label.gap != null ? this.cfg.label.gap : 1.5);
|
|
4222
|
+
fits = function(idx){
|
|
4223
|
+
var prev, i$, len$, i, tick;
|
|
4224
|
+
prev = null;
|
|
4225
|
+
for (i$ = 0, len$ = idx.length; i$ < len$; ++i$) {
|
|
4226
|
+
i = idx[i$];
|
|
4227
|
+
tick = ticks[i];
|
|
4228
|
+
if (prev != null && tick._start - (prev._start + prev._size) < gap) {
|
|
4229
|
+
return false;
|
|
4230
|
+
}
|
|
4231
|
+
prev = tick;
|
|
4232
|
+
}
|
|
4233
|
+
return true;
|
|
4234
|
+
};
|
|
4235
|
+
sel = [0];
|
|
4236
|
+
if (ticks.length > 1) {
|
|
4237
|
+
if (this.cfg.label.strategy !== 'ends') {
|
|
4238
|
+
k = 1;
|
|
4239
|
+
while (k < ticks.length && !fits((fn$()))) {
|
|
4240
|
+
k++;
|
|
4241
|
+
}
|
|
4242
|
+
res$ = [];
|
|
4243
|
+
for (i$ = 0, to$ = ticks.length; k < 0 ? i$ > to$ : i$ < to$; i$ += k) {
|
|
4244
|
+
i = i$;
|
|
4245
|
+
res$.push(i);
|
|
4246
|
+
}
|
|
4247
|
+
sel = res$;
|
|
4248
|
+
} else {
|
|
4249
|
+
tol = this.cfg.label.tolerance != null ? this.cfg.label.tolerance : 0.2;
|
|
4250
|
+
ref$ = [ticks[0]._c, ticks[ticks.length - 1]._c], lo = ref$[0], hi = ref$[1];
|
|
4251
|
+
pick = function(p){
|
|
4252
|
+
var ret, i$, i, target, best, j$, to$, j;
|
|
4253
|
+
ret = [];
|
|
4254
|
+
for (i$ = 0; i$ <= p; ++i$) {
|
|
4255
|
+
i = i$;
|
|
4256
|
+
target = lo + (hi - lo) * i / p;
|
|
4257
|
+
best = 0;
|
|
4258
|
+
for (j$ = 1, to$ = ticks.length; j$ < to$; ++j$) {
|
|
4259
|
+
j = j$;
|
|
4260
|
+
if (Math.abs(ticks[j]._c - target) < Math.abs(ticks[best]._c - target)) {
|
|
4261
|
+
best = j;
|
|
4262
|
+
}
|
|
4263
|
+
}
|
|
4264
|
+
if (ret[ret.length - 1] !== best) {
|
|
4265
|
+
ret.push(best);
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4268
|
+
return ret;
|
|
4269
|
+
};
|
|
4270
|
+
even = function(idx){
|
|
4271
|
+
var mean, i$, to$, i, d;
|
|
4272
|
+
if (idx.length < 3) {
|
|
4273
|
+
return true;
|
|
4274
|
+
}
|
|
4275
|
+
mean = (ticks[idx[idx.length - 1]]._c - ticks[idx[0]]._c) / (idx.length - 1);
|
|
4276
|
+
if (!mean) {
|
|
4277
|
+
return true;
|
|
4278
|
+
}
|
|
4279
|
+
for (i$ = 0, to$ = idx.length - 1; i$ < to$; ++i$) {
|
|
4280
|
+
i = i$;
|
|
4281
|
+
d = ticks[idx[i + 1]]._c - ticks[idx[i]]._c;
|
|
4282
|
+
if (Math.abs(d - mean) > mean * tol + 0.5) {
|
|
4283
|
+
return false;
|
|
4284
|
+
}
|
|
4285
|
+
}
|
|
4286
|
+
return true;
|
|
4287
|
+
};
|
|
4288
|
+
for (i$ = ticks.length - 1; i$ >= 1; --i$) {
|
|
4289
|
+
p = i$;
|
|
4290
|
+
idx = pick(p);
|
|
4291
|
+
if (idx.length > 1 && even(idx) && fits(idx)) {
|
|
4292
|
+
sel = idx;
|
|
4293
|
+
break;
|
|
4294
|
+
}
|
|
4295
|
+
}
|
|
4296
|
+
}
|
|
4297
|
+
}
|
|
4298
|
+
picked = {};
|
|
4299
|
+
sel.map(function(it){
|
|
4300
|
+
return picked[it] = true;
|
|
4301
|
+
});
|
|
4302
|
+
ticks.map(function(tick, i){
|
|
4303
|
+
return tick.n.t.style.opacity = picked[i] ? 1 : 0;
|
|
4304
|
+
});
|
|
4305
|
+
shown = ticks.filter(function(tick, i){
|
|
4306
|
+
return picked[i];
|
|
4307
|
+
});
|
|
4308
|
+
this._n.label.style.fill = this.cfg.caption.color;
|
|
4309
|
+
this._n.label.style.fontSize = this.cfg.caption.font.size ? this.cfg.caption.font.size + "" || '' : void 8;
|
|
4310
|
+
this._n.label.setAttribute('class', (this.cfg.caption.font.family || {}).className || '');
|
|
4311
|
+
this.caption();
|
|
4312
|
+
this._n.sideNote.map(function(n, i){
|
|
4313
|
+
var cfg, font;
|
|
4314
|
+
cfg = this$.cfg[['sideNoteStart', 'sideNoteEnd'][i]] || {};
|
|
4315
|
+
font = cfg.font || {};
|
|
4316
|
+
n.textContent = !cfg.show
|
|
4317
|
+
? ''
|
|
4318
|
+
: cfg.text || '';
|
|
4319
|
+
n.style.fill = cfg.color;
|
|
4320
|
+
n.style.fontSize = font.size ? font.size + "" || '' : void 8;
|
|
4321
|
+
return n.setAttribute('class', (font.family || {}).className || '');
|
|
4322
|
+
});
|
|
4323
|
+
mm3 = (this.cfg.caption.position || 0) % 3;
|
|
4324
|
+
md3 = Math.floor((this.cfg.caption.position || 0) / 3);
|
|
4325
|
+
size = Math.max.apply(Math, [0].concat(shown.map(function(it){
|
|
4326
|
+
return it._sizeAlt;
|
|
4327
|
+
})));
|
|
4328
|
+
delta = this.cfg.tick.inner + this.cfg.label.padding + this.cfg.caption.padding + size;
|
|
4329
|
+
if (this.dir < 2) {
|
|
4330
|
+
this._n.label.setAttribute('y', [-2, delta][md3]);
|
|
4331
|
+
this._n.layout.style.height = (delta + this._n.label.getBoundingClientRect().height) + "px";
|
|
4332
|
+
box = this._n.layout.getBoundingClientRect();
|
|
4333
|
+
return this._n.sideNote.map(function(n, i){
|
|
4334
|
+
var cfg, pos;
|
|
4335
|
+
cfg = this$.cfg[['sideNoteStart', 'sideNoteEnd'][i]] || {};
|
|
4336
|
+
pos = cfg.position || 0;
|
|
4337
|
+
n.setAttribute('x', [2, box.width - 2][i]);
|
|
4338
|
+
return n.setAttribute('y', [-2 - cfg.padding, delta + cfg.padding][pos]);
|
|
4339
|
+
});
|
|
4340
|
+
} else {
|
|
4341
|
+
this._n.label.setAttribute('x', 0);
|
|
4342
|
+
this._n.label.setAttribute('y', 0);
|
|
4343
|
+
this._n.layout.style.width = (delta + this._n.label.getBoundingClientRect().width) + "px";
|
|
4344
|
+
box = this._n.layout.getBoundingClientRect();
|
|
4345
|
+
xoff = [2, -delta - 2][md3];
|
|
4346
|
+
yoff = [2, box.height / 2, box.height - 2][mm3];
|
|
4347
|
+
this._n.label.setAttribute('transform', "translate(" + xoff + "," + yoff + ") rotate(90)");
|
|
4348
|
+
this._n.root.setAttribute('transform', "translate(" + (box.width - 1) + ",0)");
|
|
4349
|
+
return this._n.sideNote.map(function(n, i){
|
|
4350
|
+
var cfg, pos, xoff, yoff;
|
|
4351
|
+
cfg = this$.cfg[['sideNoteStart', 'sideNoteEnd'][i]] || {};
|
|
4352
|
+
pos = cfg.position || 0;
|
|
4353
|
+
xoff = [2 + cfg.padding, -delta - 2 - cfg.padding][pos];
|
|
4354
|
+
yoff = [2, box.height - 2][i];
|
|
4355
|
+
return n.setAttribute('transform', "translate(" + xoff + "," + yoff + ") rotate(90)");
|
|
4356
|
+
});
|
|
4357
|
+
}
|
|
4358
|
+
function fn$(){
|
|
4359
|
+
var i$, step$, to$, results$ = [];
|
|
4360
|
+
for (i$ = 0, to$ = ticks.length, step$ = k; step$ < 0 ? i$ > to$ : i$ < to$; i$ += step$) {
|
|
4361
|
+
i = i$;
|
|
4362
|
+
results$.push(i);
|
|
4363
|
+
}
|
|
4364
|
+
return results$;
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
});
|
|
4368
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
4369
|
+
(chart.utils || (chart.utils = {})).axis = axis;
|
|
4370
|
+
}
|
|
4371
|
+
function import$(obj, src){
|
|
4372
|
+
var own = {}.hasOwnProperty;
|
|
4373
|
+
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
|
4374
|
+
return obj;
|
|
4375
|
+
}
|
|
4376
|
+
}).call(this);
|
|
4377
|
+
(function(){
|
|
4378
|
+
var tip, ref$;
|
|
4379
|
+
tip = function(opt){
|
|
4380
|
+
var ref$, this$ = this;
|
|
4381
|
+
opt == null && (opt = {});
|
|
4382
|
+
this.root = typeof opt.root === 'string'
|
|
4383
|
+
? document.querySelector(opt.root)
|
|
4384
|
+
: opt.root;
|
|
4385
|
+
this.tip = typeof opt.node === 'string'
|
|
4386
|
+
? this.root.querySelector(opt.node)
|
|
4387
|
+
: opt.node;
|
|
4388
|
+
this.margin = opt.margin != null ? opt.margin : 10;
|
|
4389
|
+
this.type = opt.type === 'over' ? 'over' : 'move';
|
|
4390
|
+
this.accessor = opt.accessor;
|
|
4391
|
+
this.range = opt.range;
|
|
4392
|
+
this.zmgr = opt.zmgr;
|
|
4393
|
+
this._z = 0;
|
|
4394
|
+
this.enabled = true;
|
|
4395
|
+
if (!this.tip) {
|
|
4396
|
+
this.tip = document.createElement('div');
|
|
4397
|
+
this.tip.innerHTML = "<div ld=\"group\" style=\"font-size:.75em\"></div>\n<div ld=\"name\" style=\"font-size:.85em\"></div>\n<div ld=\"value\" style=\"font-weight:bold;font-size:1.1em;line-height:1.2em\"></div>\n<div ld=\"value-alt\" style=\"font-size:0.9em;line-height:1em\"></div>";
|
|
4398
|
+
this.root.appendChild(this.tip);
|
|
4399
|
+
ref$ = this.tip.style;
|
|
4400
|
+
ref$.padding = '.4em .5em';
|
|
4401
|
+
ref$.background = '#13171a';
|
|
4402
|
+
ref$.color = '#fff';
|
|
4403
|
+
ref$.borderRadius = '3px';
|
|
4404
|
+
ref$.boxShadow = '0 2px 4px rgba(0,0,0,.3)';
|
|
4405
|
+
ref$.lineHeight = '1.2em';
|
|
4406
|
+
ref$.fontSize = '.9em';
|
|
4407
|
+
ref$.maxWidth = "10em";
|
|
4408
|
+
ref$.wordBreak = "break-all";
|
|
4409
|
+
}
|
|
4410
|
+
ref$ = this.tip.style;
|
|
4411
|
+
ref$.position = 'absolute';
|
|
4412
|
+
ref$.zIndex = 1;
|
|
4413
|
+
ref$.top = 0;
|
|
4414
|
+
ref$.left = 0;
|
|
4415
|
+
ref$.pointerEvents = 'none';
|
|
4416
|
+
ref$.userSelect = 'none';
|
|
4417
|
+
ref$.opacity = 0;
|
|
4418
|
+
ref$.transition = 'opacity .15s ease-in-out' + (this.type === 'over' ? ', transform .15s ease-in-out' : '');
|
|
4419
|
+
this.view = new ldview({
|
|
4420
|
+
root: this.tip,
|
|
4421
|
+
text: opt.view || {
|
|
4422
|
+
group: function(arg$){
|
|
4423
|
+
var ctx;
|
|
4424
|
+
ctx = arg$.ctx;
|
|
4425
|
+
if (ctx) {
|
|
4426
|
+
return ctx.group;
|
|
4427
|
+
} else {
|
|
4428
|
+
return '';
|
|
4429
|
+
}
|
|
4430
|
+
},
|
|
4431
|
+
name: function(arg$){
|
|
4432
|
+
var ctx;
|
|
4433
|
+
ctx = arg$.ctx;
|
|
4434
|
+
if (ctx) {
|
|
4435
|
+
return ctx.name;
|
|
4436
|
+
} else {
|
|
4437
|
+
return '';
|
|
4438
|
+
}
|
|
4439
|
+
},
|
|
4440
|
+
value: function(arg$){
|
|
4441
|
+
var ctx;
|
|
4442
|
+
ctx = arg$.ctx;
|
|
4443
|
+
if (ctx) {
|
|
4444
|
+
return ctx.value;
|
|
4445
|
+
} else {
|
|
4446
|
+
return '';
|
|
4447
|
+
}
|
|
4448
|
+
},
|
|
4449
|
+
"value-alt": function(arg$){
|
|
4450
|
+
var ctx;
|
|
4451
|
+
ctx = arg$.ctx;
|
|
4452
|
+
if (ctx) {
|
|
4453
|
+
return ctx.valueAlt;
|
|
4454
|
+
} else {
|
|
4455
|
+
return '';
|
|
4456
|
+
}
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4459
|
+
});
|
|
4460
|
+
this.hide = debounce(3000, function(){
|
|
4461
|
+
this.tip.style.opacity = 0;
|
|
4462
|
+
if (this.zmgr) {
|
|
4463
|
+
return this.zmgr.remove(this._z);
|
|
4464
|
+
}
|
|
4465
|
+
});
|
|
4466
|
+
this._evthdr = {};
|
|
4467
|
+
if (this.accessor) {
|
|
4468
|
+
this.root.addEventListener(this.type === 'over' ? 'mouseover' : 'mousemove', this._evthdr.over = function(e){
|
|
4469
|
+
var data;
|
|
4470
|
+
if (!(e.target && (data = this$.accessor({
|
|
4471
|
+
evt: e
|
|
4472
|
+
})))) {
|
|
4473
|
+
return;
|
|
4474
|
+
}
|
|
4475
|
+
return this$.render({
|
|
4476
|
+
data: data,
|
|
4477
|
+
node: e.target,
|
|
4478
|
+
evt: e
|
|
4479
|
+
});
|
|
4480
|
+
});
|
|
4481
|
+
this.root.addEventListener('mouseout', this._evthdr.out = function(){
|
|
4482
|
+
return this$.hide().now();
|
|
4483
|
+
});
|
|
4484
|
+
}
|
|
4485
|
+
return this;
|
|
4486
|
+
};
|
|
4487
|
+
tip.prototype = (ref$ = Object.create(Object.prototype), ref$.destroy = function(){
|
|
4488
|
+
if (this._evthdr.over) {
|
|
4489
|
+
this.root.removeEventListener(this.type === 'over' ? 'mouseover' : 'mousemove', this._evthdr.over);
|
|
4490
|
+
}
|
|
4491
|
+
if (this._evthdr.out) {
|
|
4492
|
+
return this.root.removeEventListener('mouseout', this._evthdr.out);
|
|
4493
|
+
}
|
|
4494
|
+
}, ref$.toggle = function(it){
|
|
4495
|
+
return !(it != null)
|
|
4496
|
+
? this.enabled
|
|
4497
|
+
: this.enabled = it;
|
|
4498
|
+
}, ref$.render = function(opt){
|
|
4499
|
+
var rbox, nbox, ret, tbox, ref$, mx, my, m, nx, ny, tx, ty, rangeBox, ref1$, ref2$;
|
|
4500
|
+
opt == null && (opt = {});
|
|
4501
|
+
if (!this.enabled) {
|
|
4502
|
+
return;
|
|
4503
|
+
}
|
|
4504
|
+
this.view.ctx(opt.data);
|
|
4505
|
+
this.view.render();
|
|
4506
|
+
rbox = this.root.getBoundingClientRect();
|
|
4507
|
+
nbox = opt.node != null
|
|
4508
|
+
? (ret = opt.node.getBoundingClientRect(), ret.x = ret.x - rbox.x, ret.y = ret.y - rbox.y, ret)
|
|
4509
|
+
: opt.box != null
|
|
4510
|
+
? opt.box
|
|
4511
|
+
: {
|
|
4512
|
+
x: opt.x,
|
|
4513
|
+
y: opt.y,
|
|
4514
|
+
width: opt.width,
|
|
4515
|
+
height: opt.height
|
|
4516
|
+
};
|
|
4517
|
+
tbox = this.tip.getBoundingClientRect();
|
|
4518
|
+
ref$ = [opt.evt.clientX - rbox.x, opt.evt.clientY - rbox.y], mx = ref$[0], my = ref$[1];
|
|
4519
|
+
m = this.margin;
|
|
4520
|
+
ref$ = [nbox.x + (nbox.width != null ? nbox.width / 2 : 0), nbox.y + (nbox.height != null ? nbox.height / 2 : 0)], nx = ref$[0], ny = ref$[1];
|
|
4521
|
+
ref$ = [mx - tbox.width / 2, my - tbox.height / 2], tx = ref$[0], ty = ref$[1];
|
|
4522
|
+
ref$ = [
|
|
4523
|
+
tx + (nx < mx
|
|
4524
|
+
? 1
|
|
4525
|
+
: -1) * (m + tbox.width / 2), ty + (ny < my
|
|
4526
|
+
? 1
|
|
4527
|
+
: -1) * (m + tbox.height / 2)
|
|
4528
|
+
], tx = ref$[0], ty = ref$[1];
|
|
4529
|
+
rangeBox = this.range ? rangeBox = this.range() : rbox;
|
|
4530
|
+
ref$ = [((ref$ = (tx > (ref2$ = rangeBox.x - rbox.x) ? tx : ref2$) + tbox.width) < (ref1$ = rangeBox.width + rangeBox.x - rbox.x) ? ref$ : ref1$) - tbox.width, ((ref$ = (ty > (ref2$ = rangeBox.y - rbox.y) ? ty : ref2$) + tbox.height) < (ref1$ = rangeBox.height + rangeBox.y - rbox.y) ? ref$ : ref1$) - tbox.height], tx = ref$[0], ty = ref$[1];
|
|
4531
|
+
ref$ = this.tip.style;
|
|
4532
|
+
ref$.transform = "translate(" + tx + "px," + ty + "px)";
|
|
4533
|
+
ref$.opacity = 1;
|
|
4534
|
+
ref$.zIndex = this._z = !this.zmgr
|
|
4535
|
+
? 10
|
|
4536
|
+
: this.zmgr.add(10);
|
|
4537
|
+
return this.hide();
|
|
4538
|
+
}, ref$);
|
|
4539
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
4540
|
+
(chart.utils || (chart.utils = {})).tip = tip;
|
|
4541
|
+
}
|
|
4542
|
+
}).call(this);
|
|
4543
|
+
chart.utils.debounce = debounce;
|
|
4544
|
+
if (typeof window != 'undefined' && window !== null) { window.chart = chart; }
|
|
4545
|
+
})();
|