@plotdb/chart 3.6.0 → 3.8.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 +30 -0
- package/bundle.js +1706 -81
- package/bundle.min.js +1 -1
- package/index.js +460 -13
- package/index.min.js +1 -1
- package/package.json +1 -1
- package/utils/anim.js +152 -18
- package/utils/anim.min.js +1 -1
- package/utils/brush.js +4 -2
- package/utils/brush.min.js +1 -1
- package/utils/color.js +37 -0
- package/utils/color.min.js +1 -0
- package/utils/scale.js +235 -29
- package/utils/scale.min.js +1 -1
- package/utils/shape.js +799 -0
- package/utils/shape.min.js +1 -0
package/utils/anim.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(){
|
|
2
|
-
var svgns, now, ease, reNum, color, interpColor, interpString, interpolate, anim, join;
|
|
2
|
+
var svgns, now, ease, reNum, color, interpColor, interpString, interpolate, getV, setV, rmV, anim, join;
|
|
3
3
|
svgns = "http://www.w3.org/2000/svg";
|
|
4
4
|
now = function(){
|
|
5
5
|
if (typeof performance != 'undefined' && performance !== null) {
|
|
@@ -76,7 +76,10 @@
|
|
|
76
76
|
var ref$, ref1$;
|
|
77
77
|
return (ref$ = (ref1$ = Math.round(it)) > 0 ? ref1$ : 0) < 255 ? ref$ : 255;
|
|
78
78
|
}), r = ref$[0], g = ref$[1], bl = ref$[2];
|
|
79
|
-
|
|
79
|
+
al = isNaN(al)
|
|
80
|
+
? 1
|
|
81
|
+
: (ref$ = al > 0 ? al : 0) < 1 ? ref$ : 1;
|
|
82
|
+
if (al === 1) {
|
|
80
83
|
return "rgb(" + r + ", " + g + ", " + bl + ")";
|
|
81
84
|
} else {
|
|
82
85
|
return "rgba(" + r + ", " + g + ", " + bl + ", " + al + ")";
|
|
@@ -153,18 +156,44 @@
|
|
|
153
156
|
}
|
|
154
157
|
return interpString(a, b);
|
|
155
158
|
};
|
|
159
|
+
getV = function(node, k){
|
|
160
|
+
if (k.startsWith('style:')) {
|
|
161
|
+
return node.style.getPropertyValue(k.slice(6));
|
|
162
|
+
} else {
|
|
163
|
+
return node.getAttribute(k);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
setV = function(node, k, v){
|
|
167
|
+
if (k.startsWith('style:')) {
|
|
168
|
+
return node.style.setProperty(k.slice(6), v);
|
|
169
|
+
} else {
|
|
170
|
+
return node.setAttribute(k, v);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
rmV = function(node, k){
|
|
174
|
+
if (k.startsWith('style:')) {
|
|
175
|
+
return node.style.removeProperty(k.slice(6));
|
|
176
|
+
} else {
|
|
177
|
+
return node.removeAttribute(k);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
156
180
|
anim = function(opt){
|
|
157
181
|
var this$ = this;
|
|
158
182
|
opt == null && (opt = {});
|
|
159
183
|
this._manual = !!opt.manual;
|
|
160
184
|
this._now = 0;
|
|
161
|
-
this.
|
|
185
|
+
this._base = 0;
|
|
186
|
+
this._since = now();
|
|
187
|
+
this._speed = 1;
|
|
188
|
+
this._frozen = false;
|
|
189
|
+
this._dur = 350;
|
|
190
|
+
this._back = 0;
|
|
162
191
|
this._raf = null;
|
|
163
192
|
this._list = new Map();
|
|
164
193
|
this.evtHandler = {};
|
|
165
194
|
this._tick = function(t){
|
|
166
195
|
this$._raf = null;
|
|
167
|
-
if (this$._manual) {
|
|
196
|
+
if (this$._manual || this$._frozen) {
|
|
168
197
|
return;
|
|
169
198
|
}
|
|
170
199
|
this$._apply(this$.time());
|
|
@@ -200,9 +229,80 @@
|
|
|
200
229
|
time: function(){
|
|
201
230
|
if (this._manual) {
|
|
202
231
|
return this._now;
|
|
232
|
+
} else if (this._frozen) {
|
|
233
|
+
return this._base;
|
|
203
234
|
} else {
|
|
204
|
-
return now() - this.
|
|
235
|
+
return this._base + (now() - this._since) * this._speed;
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
_rebase: function(){
|
|
239
|
+
this._base = this.time();
|
|
240
|
+
return this._since = now();
|
|
241
|
+
},
|
|
242
|
+
duration: function(v){
|
|
243
|
+
if (!arguments.length) {
|
|
244
|
+
return this._dur;
|
|
205
245
|
}
|
|
246
|
+
v = +v;
|
|
247
|
+
this._dur = isNaN(v) || v < 0 ? 350 : v;
|
|
248
|
+
return this;
|
|
249
|
+
},
|
|
250
|
+
speed: function(v){
|
|
251
|
+
if (!arguments.length) {
|
|
252
|
+
return this._speed;
|
|
253
|
+
}
|
|
254
|
+
v = +v;
|
|
255
|
+
if (isNaN(v) || v <= 0) {
|
|
256
|
+
v = 1;
|
|
257
|
+
}
|
|
258
|
+
if (v === this._speed) {
|
|
259
|
+
return this;
|
|
260
|
+
}
|
|
261
|
+
if (!this._manual) {
|
|
262
|
+
this._rebase();
|
|
263
|
+
}
|
|
264
|
+
this._speed = v;
|
|
265
|
+
return this;
|
|
266
|
+
},
|
|
267
|
+
paused: function(){
|
|
268
|
+
return this._frozen;
|
|
269
|
+
},
|
|
270
|
+
pause: function(){
|
|
271
|
+
if (this._frozen) {
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
if (!this._manual) {
|
|
275
|
+
this._rebase();
|
|
276
|
+
}
|
|
277
|
+
this._frozen = true;
|
|
278
|
+
if (this._raf) {
|
|
279
|
+
cancelAnimationFrame(this._raf);
|
|
280
|
+
}
|
|
281
|
+
this._raf = null;
|
|
282
|
+
return this;
|
|
283
|
+
},
|
|
284
|
+
resume: function(){
|
|
285
|
+
if (!this._frozen) {
|
|
286
|
+
return this;
|
|
287
|
+
}
|
|
288
|
+
this._since = now();
|
|
289
|
+
this._frozen = false;
|
|
290
|
+
if (this._list.size) {
|
|
291
|
+
this._kick();
|
|
292
|
+
}
|
|
293
|
+
return this;
|
|
294
|
+
},
|
|
295
|
+
ago: function(ms, fn){
|
|
296
|
+
this._back = ms || 0;
|
|
297
|
+
try {
|
|
298
|
+
fn();
|
|
299
|
+
} finally {
|
|
300
|
+
this._back = 0;
|
|
301
|
+
}
|
|
302
|
+
if (ms) {
|
|
303
|
+
this._apply(this.time());
|
|
304
|
+
}
|
|
305
|
+
return this;
|
|
206
306
|
},
|
|
207
307
|
manual: function(v){
|
|
208
308
|
if (!arguments.length) {
|
|
@@ -220,7 +320,8 @@
|
|
|
220
320
|
}
|
|
221
321
|
this._raf = null;
|
|
222
322
|
} else {
|
|
223
|
-
this.
|
|
323
|
+
this._base = this._now;
|
|
324
|
+
this._since = now();
|
|
224
325
|
this._manual = false;
|
|
225
326
|
if (this._list.size) {
|
|
226
327
|
this._kick();
|
|
@@ -233,6 +334,7 @@
|
|
|
233
334
|
if (!this._manual) {
|
|
234
335
|
this.manual(true);
|
|
235
336
|
}
|
|
337
|
+
dt = dt * this._speed;
|
|
236
338
|
this._now += dt;
|
|
237
339
|
this._apply(this._now);
|
|
238
340
|
this.fire('step', this._now, dt);
|
|
@@ -259,7 +361,7 @@
|
|
|
259
361
|
},
|
|
260
362
|
_kick: function(){
|
|
261
363
|
var this$ = this;
|
|
262
|
-
if (this._manual || this._raf) {
|
|
364
|
+
if (this._manual || this._frozen || this._raf) {
|
|
263
365
|
return;
|
|
264
366
|
}
|
|
265
367
|
if (!(typeof requestAnimationFrame != 'undefined' && requestAnimationFrame !== null)) {
|
|
@@ -270,11 +372,12 @@
|
|
|
270
372
|
return this._raf = requestAnimationFrame(this._tick);
|
|
271
373
|
},
|
|
272
374
|
tween: function(node, attrs, opt){
|
|
273
|
-
var dur, delay, ez, immediate, item, start, k, v;
|
|
375
|
+
var r, dur, delay, ez, immediate, item, start, k, v;
|
|
274
376
|
attrs == null && (attrs = {});
|
|
275
377
|
opt == null && (opt = {});
|
|
276
|
-
|
|
277
|
-
|
|
378
|
+
r = this._dur / 350;
|
|
379
|
+
dur = (opt.duration != null ? opt.duration : 350) * r;
|
|
380
|
+
delay = (opt.delay || 0) * r;
|
|
278
381
|
ez = typeof opt.ease === 'function'
|
|
279
382
|
? opt.ease
|
|
280
383
|
: ease[opt.ease || 'cubic-in-out'] || ease.cubicInOut;
|
|
@@ -287,17 +390,26 @@
|
|
|
287
390
|
if (opt.end) {
|
|
288
391
|
item.cb.push(opt.end);
|
|
289
392
|
}
|
|
290
|
-
start = this.time() + delay;
|
|
393
|
+
start = this.time() - this._back + delay;
|
|
291
394
|
for (k in attrs) {
|
|
292
395
|
v = attrs[k];
|
|
293
396
|
if (!(v != null)) {
|
|
294
|
-
node
|
|
397
|
+
rmV(node, k);
|
|
295
398
|
delete item.attr[k];
|
|
296
399
|
continue;
|
|
297
400
|
}
|
|
298
401
|
if (immediate) {
|
|
299
|
-
node
|
|
402
|
+
setV(node, k, typeof v === 'function' ? v(1) : v);
|
|
403
|
+
delete item.attr[k];
|
|
404
|
+
} else if (k.startsWith('style:') && !node.style.getPropertyValue(k.slice(6)) && window.getComputedStyle(node).getPropertyValue(k.slice(6)) === v + "") {
|
|
300
405
|
delete item.attr[k];
|
|
406
|
+
} else if (typeof v === 'function') {
|
|
407
|
+
item.attr[k] = {
|
|
408
|
+
fn: v,
|
|
409
|
+
start: start,
|
|
410
|
+
dur: dur > 0 ? dur : 0,
|
|
411
|
+
ease: ez
|
|
412
|
+
};
|
|
301
413
|
} else {
|
|
302
414
|
item.attr[k] = {
|
|
303
415
|
to: v,
|
|
@@ -342,15 +454,25 @@
|
|
|
342
454
|
if (t < a.start) {
|
|
343
455
|
continue;
|
|
344
456
|
}
|
|
457
|
+
if (a.fn) {
|
|
458
|
+
p = a.dur ? (ref2$ = (t - a.start) / a.dur) < 1 ? ref2$ : 1 : 1;
|
|
459
|
+
setV(node, k, a.fn(p >= 1
|
|
460
|
+
? 1
|
|
461
|
+
: a.ease(p)));
|
|
462
|
+
if (p >= 1) {
|
|
463
|
+
delete item.attr[k];
|
|
464
|
+
}
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
345
467
|
if (!a.interp) {
|
|
346
|
-
a.interp = interpolate(node
|
|
468
|
+
a.interp = interpolate(getV(node, k), a.to);
|
|
347
469
|
}
|
|
348
470
|
p = a.dur ? (ref2$ = (t - a.start) / a.dur) < 1 ? ref2$ : 1 : 1;
|
|
349
471
|
if (p >= 1) {
|
|
350
|
-
node
|
|
472
|
+
setV(node, k, a.to);
|
|
351
473
|
delete item.attr[k];
|
|
352
474
|
} else {
|
|
353
|
-
node
|
|
475
|
+
setV(node, k, a.interp(a.ease(p)));
|
|
354
476
|
}
|
|
355
477
|
}
|
|
356
478
|
if (!(fn$()).length) {
|
|
@@ -368,7 +490,7 @@
|
|
|
368
490
|
}
|
|
369
491
|
});
|
|
370
492
|
join = function(arg$){
|
|
371
|
-
var root, tag, ref$, cls, data, key, olds, map, enter, update, nodes, exit;
|
|
493
|
+
var root, tag, ref$, cls, data, key, olds, map, enter, update, nodes, exit, nx, i$, i, n;
|
|
372
494
|
root = arg$.root, tag = (ref$ = arg$.tag) != null ? ref$ : 'g', cls = arg$.cls, data = (ref$ = arg$.data) != null
|
|
373
495
|
? ref$
|
|
374
496
|
: [], key = arg$.key;
|
|
@@ -400,12 +522,24 @@
|
|
|
400
522
|
if (cls) {
|
|
401
523
|
n.setAttribute('class', cls);
|
|
402
524
|
}
|
|
403
|
-
|
|
525
|
+
n._entering = true;
|
|
404
526
|
enter.push(n);
|
|
405
527
|
}
|
|
406
528
|
n.__data__ = d;
|
|
407
529
|
return nodes.push(n);
|
|
408
530
|
});
|
|
531
|
+
nx = null;
|
|
532
|
+
for (i$ = nodes.length - 1; i$ >= 0; --i$) {
|
|
533
|
+
i = i$;
|
|
534
|
+
n = nodes[i];
|
|
535
|
+
if (!n._entering) {
|
|
536
|
+
nx = n;
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
delete n._entering;
|
|
540
|
+
root.insertBefore(n, nx);
|
|
541
|
+
nx = n;
|
|
542
|
+
}
|
|
409
543
|
exit = exit.concat(Array.from(map.values()));
|
|
410
544
|
return {
|
|
411
545
|
enter: enter,
|
package/utils/anim.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var n,
|
|
1
|
+
!function(){var n,c,l,r,s,u,f,_,p,d,t,e;n=function(){return("undefined"!=typeof performance&&null!==performance?performance:Date).now()},c={linear:function(t){return t},cubicInOut:function(t){return(t*=2)<=1?t*t*t/2:((t-=2)*t*t+2)/2},cubicOut:function(t){return--t*t*t+1},quadInOut:function(t){return(t*=2)<=1?t*t/2:(--t*(2-t)+1)/2}},l=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,r=function(t){var e,n;return"string"!=typeof t?null:(t=t.trim(),(e=/^#([0-9a-f]{3,4})$/i.exec(t))?[(n=e[1].split("").map(function(t){return parseInt(t+t,16)}))[0],n[1],n[2],null!=n[3]?n[3]/255:1]:(e=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(t))?(n=[0,1,2].map(function(t){return parseInt(e[1].substr(2*t,2),16)})).concat([e[2]?parseInt(e[2],16)/255:1]):!(e=/^rgba?\(([^)]+)\)$/i.exec(t))||(n=e[1].split(/[\s,\/]+/).filter(function(t){return t}).map(function(t){return parseFloat(t)})).length<3||n.slice(0,3).some(function(t){return isNaN(t)})?null:[n[0],n[1],n[2],null==n[3]||isNaN(n[3])?1:n[3]])},s=function(u,a){return function(e){var t=[0,1,2,3].map(function(t){return u[t]+(a[t]-u[t])*e}),n=t[0],i=t[1],r=t[2],s=t[3];return n=(t=[n,i,r].map(function(t){return(t=0<(t=Math.round(t))?t:0)<255?t:255}))[0],i=t[1],r=t[2],1===(s=!isNaN(s)&&(t=0<s?s:0)<1?t:1)?"rgb("+n+", "+i+", "+r+")":"rgba("+n+", "+i+", "+r+", "+s+")"}},u=function(t,e){var n,i,r,s,u,a,o;for(e+="",n=(t+="").match(l)||[],i=[],l.lastIndex=s=r=0;u=l.exec(e);)u.index>r&&i.push(e.slice(r,u.index)),a=+u[0],o=null!=n[s]?+n[s]:null,i.push(null!=o&&o!==a?{a:o,b:a}:u[0]),r=l.lastIndex,s++;return r<e.length&&i.push(e.slice(r)),i.some(function(t){return"object"==typeof t})?function(e){return i.map(function(t){return"object"==typeof t?t.a+(t.b-t.a)*e:t}).join("")}:function(){return e}},f=function(e,n){var t,i;return"number"==typeof n?(e=parseFloat(e),isNaN(e)&&(e=0),function(t){return e+(n-e)*t}):null==e?function(){return n}:(t=r(n))?(i=r(e))?s(i,t):function(){return n}:u(e,n)},_=function(t,e){return e.startsWith("style:")?t.style.getPropertyValue(e.slice(6)):t.getAttribute(e)},p=function(t,e,n){return e.startsWith("style:")?t.style.setProperty(e.slice(6),n):t.setAttribute(e,n)},d=function(t,e){return e.startsWith("style:")?t.style.removeProperty(e.slice(6)):t.removeAttribute(e)},(t=function(t){var e=this;return this._manual=!!(t=null==t?{}:t).manual,this._now=0,this._base=0,this._since=n(),this._speed=1,this._frozen=!1,this._dur=350,this._back=0,this._raf=null,this._list=new Map,this.evtHandler={},this._tick=function(t){if(e._raf=null,!e._manual&&!e._frozen)return e._apply(e.time()),e._list.size?e._kick():void 0},this}).prototype=((t,e)=>{var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t})(Object.create(Object.prototype),{on:function(t,n){var i=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=i.evtHandler)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,i,r,s=[],u=[],a=1,o=arguments.length;a<o;++a)u.push(arguments[a]);for(e=u,a=0,i=(n=this.evtHandler[t]||[]).length;a<i;++a)r=n[a],s.push(r.apply(this,e));return s},time:function(){return this._manual?this._now:this._frozen?this._base:this._base+(n()-this._since)*this._speed},_rebase:function(){return this._base=this.time(),this._since=n()},duration:function(t){return arguments.length?(t=+t,this._dur=isNaN(t)||t<0?350:t,this):this._dur},speed:function(t){return arguments.length?(t=+t,(t=isNaN(t)||t<=0?1:t)!==this._speed&&(this._manual||this._rebase(),this._speed=t),this):this._speed},paused:function(){return this._frozen},pause:function(){return this._frozen||(this._manual||this._rebase(),this._frozen=!0,this._raf&&cancelAnimationFrame(this._raf),this._raf=null),this},resume:function(){return this._frozen&&(this._since=n(),this._frozen=!1,this._list.size)&&this._kick(),this},ago:function(t,e){this._back=t||0;try{e()}finally{this._back=0}return t&&this._apply(this.time()),this},manual:function(t){return arguments.length?((t=!!t)!==this._manual&&(t?(this._now=this.time(),this._manual=!0,this._raf&&cancelAnimationFrame(this._raf),this._raf=null):(this._base=this._now,this._since=n(),this._manual=!1,this._list.size&&this._kick())),this):this._manual},step:function(t){return null==t&&(t=1e3/60),this._manual||this.manual(!0),t*=this._speed,this._now+=t,this._apply(this._now),this.fire("step",this._now,t),this},seek:function(t){return this._manual||this.manual(!0),this._now=t,this._apply(this._now),this.fire("step",this._now,0),this},busy:function(){return 0<this._list.size},flush:function(){return this._apply(1/0),this},interrupt:function(t){return this._list.delete(t)},_kick:function(){var t=this;if(!(this._manual||this._frozen||this._raf))return"undefined"==typeof requestAnimationFrame||null===requestAnimationFrame?setTimeout(function(){return t._tick()},16):this._raf=requestAnimationFrame(this._tick)},tween:function(t,e,n){var i,r,s,u,a,o,l,h;for(l in null==e&&(e={}),r=this._dur/350,i=(null!=(n=null==n?{}:n).duration?n.duration:350)*r,r=(n.delay||0)*r,s="function"==typeof n.ease?n.ease:c[n.ease||"cubic-in-out"]||c.cubicInOut,u=i<=0&&r<=0||!this._manual&&"undefined"!=typeof document&&null!==document&&document.hidden,(a=this._list.get(t)||{attr:{},cb:[]}).remove=!!n.remove,n.end&&a.cb.push(n.end),o=this.time()-this._back+r,e)null==(h=e[l])?(d(t,l),delete a.attr[l]):u?(p(t,l,"function"==typeof h?h(1):h),delete a.attr[l]):l.startsWith("style:")&&!t.style.getPropertyValue(l.slice(6))&&window.getComputedStyle(t).getPropertyValue(l.slice(6))===h+""?delete a.attr[l]:a.attr[l]="function"==typeof h?{fn:h,start:o,dur:0<i?i:0,ease:s}:{to:h,start:o,dur:0<i?i:0,ease:s};return this._list.set(t,a),u&&!(()=>{var t=[];for(l in a.attr)t.push(l);return t})().length?this._done(t,a):this._manual||this._kick(),this},_done:function(e,t){return this._list.delete(e),t.remove&&e.parentNode&&e.parentNode.removeChild(e),t.cb.map(function(t){return t.call(e)})},_apply:function(t){for(var e,n,i,r,s,u,a,o,l=[],h=0,c=(e=Array.from(this._list)).length;h<c;++h)if(i=(n=e[h])[0],r=n[1],this._list.get(i)===r){for(s in n=r.attr)t<(u=n[s]).start||(u.fn?(a=u.dur&&(o=(t-u.start)/u.dur)<1?o:1,p(i,s,u.fn(1<=a?1:u.ease(a))),1<=a&&delete r.attr[s]):(u.interp||(u.interp=f(_(i,s),u.to)),1<=(a=u.dur&&(o=(t-u.start)/u.dur)<1?o:1)?(p(i,s,u.to),delete r.attr[s]):p(i,s,u.interp(u.ease(a)))));(()=>{var t=[];for(s in r.attr)t.push(s);return t})().length||l.push(this._done(i,r))}return l}}),e=function(t){var e,i,r,s,u,n,a,o,l,h=t.root,c=null!=(e=t.tag)?e:"g",f=t.cls,_=null!=(e=t.data)?e:[],p=t.key;for(p=p||function(t,e){return e},t=Array.from(h.childNodes).filter(function(t){return 1===t.nodeType&&t.tagName===c&&(!f||t.classList.contains(f))}),i=new Map,r=(e=[[],[],[],[]])[0],s=e[1],u=e[2],n=e[3],t.map(function(t,e){e=p(t.__data__,e);return i.has(e)?n.push(t):i.set(e,t)}),_.map(function(t,e){var n,e=p(t,e);return((n=i.get(e))?(i.delete(e),s):(n=document.createElementNS("http://www.w3.org/2000/svg",c),f&&n.setAttribute("class",f),n._entering=!0,r)).push(n),n.__data__=t,u.push(n)}),a=null,o=u.length-1;0<=o;--o)a=((l=u[o])._entering&&(delete l._entering,h.insertBefore(l,a)),l);return n=n.concat(Array.from(i.values())),{enter:r,update:s,exit:n,nodes:u}},t.ease=c,t.interpolate=f,t.join=e,"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).anim=t)}.call(this);
|
package/utils/brush.js
CHANGED
|
@@ -90,8 +90,10 @@
|
|
|
90
90
|
this._g = g;
|
|
91
91
|
g.setAttribute('fill', 'none');
|
|
92
92
|
g.setAttribute('pointer-events', 'all');
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
if (((typeof navigator != 'undefined' && navigator !== null) && navigator.maxTouchPoints) || 'ontouchstart' in g) {
|
|
94
|
+
g.style.touchAction = 'none';
|
|
95
|
+
g.style.setProperty('-webkit-tap-highlight-color', "rgba(0,0,0,0)");
|
|
96
|
+
}
|
|
95
97
|
mk = function(cls, type, attrs){
|
|
96
98
|
var n, k, v;
|
|
97
99
|
attrs == null && (attrs = {});
|
package/utils/brush.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var t;(t=function(t){return this.dir="y"===(t=null==t?{}:t).dir?"y":"x",this._extent=[[0,0],[1,1]],this._sel=null,this._g=null,this.evtHandler={},this}).prototype=((t,e)=>{var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t})(Object.create(Object.prototype),{on:function(t,n){var i=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=i.evtHandler)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,i,r,s=[],o=[],h=1,u=arguments.length;h<u;++h)o.push(arguments[h]);for(e=o,h=0,i=(n=this.evtHandler[t]||[]).length;h<i;++h)r=n[h],s.push(r.apply(this,e));return s},extent:function(t){return arguments.length?(this._extent=t,this._render(),this):this._extent},selection:function(){return this._sel?this._sel.slice():null},attached:function(){return!!this._g},_span:function(){var t="x"===this.dir?0:1;return[this._extent[0][t],this._extent[1][t]]},_emit:function(t,e){return this.fire(t,{type:t,selection:this.selection(),sourceEvent:e||null,target:this})},move:function(t,e){var n=this;return this._sel=null!=t?[+t[0],+t[1]]:null,this._render(),["start","brush","end"].map(function(t){return n._emit(t,e)}),this},clear:function(t){return this.move(null,t)},attach:function(o){var e,t,n,i=this;return this._g!==o&&(this._g&&this.detach(),o.__brush&&o.__brush!==this&&o.__brush.detach(),((o.__brush=this)._g=o).setAttribute("fill","none"),o.setAttribute("pointer-events","all"),o.style.touchAction="none",o.style.
|
|
1
|
+
!function(){var t;(t=function(t){return this.dir="y"===(t=null==t?{}:t).dir?"y":"x",this._extent=[[0,0],[1,1]],this._sel=null,this._g=null,this.evtHandler={},this}).prototype=((t,e)=>{var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t})(Object.create(Object.prototype),{on:function(t,n){var i=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=i.evtHandler)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,i,r,s=[],o=[],h=1,u=arguments.length;h<u;++h)o.push(arguments[h]);for(e=o,h=0,i=(n=this.evtHandler[t]||[]).length;h<i;++h)r=n[h],s.push(r.apply(this,e));return s},extent:function(t){return arguments.length?(this._extent=t,this._render(),this):this._extent},selection:function(){return this._sel?this._sel.slice():null},attached:function(){return!!this._g},_span:function(){var t="x"===this.dir?0:1;return[this._extent[0][t],this._extent[1][t]]},_emit:function(t,e){return this.fire(t,{type:t,selection:this.selection(),sourceEvent:e||null,target:this})},move:function(t,e){var n=this;return this._sel=null!=t?[+t[0],+t[1]]:null,this._render(),["start","brush","end"].map(function(t){return n._emit(t,e)}),this},clear:function(t){return this.move(null,t)},attach:function(o){var e,t,n,i=this;return this._g!==o&&(this._g&&this.detach(),o.__brush&&o.__brush!==this&&o.__brush.detach(),((o.__brush=this)._g=o).setAttribute("fill","none"),o.setAttribute("pointer-events","all"),("undefined"!=typeof navigator&&null!==navigator&&navigator.maxTouchPoints||"ontouchstart"in o)&&(o.style.touchAction="none",o.style.setProperty("-webkit-tap-highlight-color","rgba(0,0,0,0)")),t="x"===this.dir?["w","e"]:["n","s"],n="x"===this.dir?"ew-resize":"ns-resize",this._n={overlay:(e=function(t,e,n){var i,r,s;for(r in null==n&&(n={}),(i=o.querySelector(":scope > rect."+t.split(" ").join("."))||o.appendChild(document.createElementNS("http://www.w3.org/2000/svg","rect"))).setAttribute("class",t),i.__data__={type:e},n)s=n[r],i.setAttribute(r,s);return i})("overlay","overlay",{"pointer-events":"all",cursor:"crosshair"}),selection:e("selection","selection",{cursor:"move",fill:"#777","fill-opacity":.3,stroke:"#fff","shape-rendering":"crispEdges"}),handle:t.map(function(t){return e("handle handle--"+t,t,{cursor:n})})},o.addEventListener("pointerdown",this._down=function(t){return i._start(t)})),this._render(),this},detach:function(){var t,e,n,i;if(this._g){for(this._g.removeEventListener("pointerdown",this._down),t=0,n=(e=[this._n.overlay,this._n.selection].concat(this._n.handle)).length;t<n;++t)(i=e[t]).parentNode&&i.parentNode.removeChild(i);return this._g.__brush===this&&(this._g.__brush=null),this._g=null}},_render:function(){var t,e,n,i,r,s,o,h,u,l,a,c,_,d,p=this;if(this._g){if(e=(i=(t=this._extent)[0])[0],d=i[1],n=(i=t[1])[0],i=i[1],(h=this._n.overlay).setAttribute("x",e),h.setAttribute("y",d),h.setAttribute("width",n-e),h.setAttribute("height",i-d),this._sel)return h=(t=this._sel)[0],u=t[1],t="x"===this.dir?[h,d,u,i]:[e,h,n,u],l=t[0],a=t[1],c=t[2],_=t[3],(d=this._n.selection).style.display="",d.setAttribute("x",l),d.setAttribute("y",a),d.setAttribute("width",c-l),d.setAttribute("height",_-a),this._n.handle.map(function(t,e){return t.style.display="","x"===p.dir?(t.setAttribute("x",(e?c:l)-3),t.setAttribute("y",a-3),t.setAttribute("width",6),t.setAttribute("height",_-a+6)):(t.setAttribute("x",l-3),t.setAttribute("y",(e?_:a)-3),t.setAttribute("width",c-l+6),t.setAttribute("height",6))});for(r=0,s=(t=[this._n.selection].concat(this._n.handle)).length;r<s;++r)(o=t[r]).style.display="none",["x","y","width","height"].map(v)}function v(t){return o.removeAttribute(t)}},_pos:function(t){var e=this._g.getScreenCTM();return e?(t=new DOMPoint(t.clientX,t.clientY).matrixTransform(e.inverse()),"x"===this.dir?t.x:t.y):0},_start:function(t){var e,n,s,o,h,u,l,a,i,r,c,_,d=this;if((null==t.button||0===t.button)&&(e=(t.target.__data__||{}).type))return t.stopImmediatePropagation(),t.preventDefault(),n=this._span(),s=n[0],o=n[1],h=function(t){return(t=s<t?t:s)<o?t:o},u=this._pos(t),l=this._sel?this._sel.slice():null,"new"===(a="selection"===e?"move":"w"!==e&&"n"!==e||!l?"e"!==e&&"s"!==e||!l?"new":"hi":"lo")&&(u=h(u)),i=!1,this._emit("start",t),r=function(t){var e,n,i,r=d._pos(t);return"move"===a?(e=(i=(e=r-u)>(i=s-l[0])?e:i)<(n=o-l[1])?i:n,d._sel=[l[0]+e,l[1]+e]):(i="new"===a?u:"lo"===a?l[1]:l[0],r=h(r),d._sel=[Math.min(i,r),Math.max(i,r)]),d._render(),d._emit("brush",t)},c=function(t){return i=!0,r(t)},_=function(t){var e;return window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",_),window.removeEventListener("pointercancel",_),i||"move"===a||(d._sel=null),d._sel&&d._sel[0]===d._sel[1]&&(d._sel=null),d._render(),i&&(e=function(t){return t.stopImmediatePropagation(),t.preventDefault()},window.addEventListener("click",e,!0),setTimeout(function(){return window.removeEventListener("click",e,!0)},0)),d._emit("end",t)},window.addEventListener("pointermove",c),window.addEventListener("pointerup",_),window.addEventListener("pointercancel",_)}}),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).brush=t)}.call(this);
|
package/utils/color.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
(function(){
|
|
2
|
+
var clamp, turbo, discrete, quantize, color;
|
|
3
|
+
clamp = function(v){
|
|
4
|
+
return Math.max(0, Math.min(255, Math.round(v)));
|
|
5
|
+
};
|
|
6
|
+
turbo = function(t){
|
|
7
|
+
var r, g, b;
|
|
8
|
+
t = Math.max(0, Math.min(1, t));
|
|
9
|
+
r = clamp(34.61 + t * (1172.33 - t * (10793.56 - t * (33300.12 - t * (38394.49 - t * 14825.05)))));
|
|
10
|
+
g = clamp(23.31 + t * (557.33 + t * (1225.33 - t * (3574.96 - t * (1073.77 + t * 707.56)))));
|
|
11
|
+
b = clamp(27.2 + t * (3211.1 - t * (15327.97 - t * (27814 - t * (22569.18 - t * 6838.66)))));
|
|
12
|
+
return "rgb(" + r + ", " + g + ", " + b + ")";
|
|
13
|
+
};
|
|
14
|
+
discrete = function(range){
|
|
15
|
+
var n;
|
|
16
|
+
n = range.length;
|
|
17
|
+
return function(t){
|
|
18
|
+
return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
quantize = function(interpolator, n){
|
|
22
|
+
var i$, i, results$ = [];
|
|
23
|
+
for (i$ = 0; i$ < n; ++i$) {
|
|
24
|
+
i = i$;
|
|
25
|
+
results$.push(interpolator(i / (n - 1)));
|
|
26
|
+
}
|
|
27
|
+
return results$;
|
|
28
|
+
};
|
|
29
|
+
color = {
|
|
30
|
+
turbo: turbo,
|
|
31
|
+
discrete: discrete,
|
|
32
|
+
quantize: quantize
|
|
33
|
+
};
|
|
34
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
35
|
+
(chart.utils || (chart.utils = {})).color = color;
|
|
36
|
+
}
|
|
37
|
+
}).call(this);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(){var n=function(t){return Math.max(0,Math.min(255,Math.round(t)))},t={turbo:function(t){return t=Math.max(0,Math.min(1,t)),"rgb("+n(34.61+t*(1172.33-t*(10793.56-t*(33300.12-t*(38394.49-14825.05*t)))))+", "+n(23.31+t*(557.33+t*(1225.33-t*(3574.96-t*(1073.77+707.56*t)))))+", "+n(27.2+t*(3211.1-t*(15327.97-t*(27814-t*(22569.18-6838.66*t)))))+")"},discrete:function(n){var r=n.length;return function(t){return n[Math.max(0,Math.min(r-1,Math.floor(t*r)))]}},quantize:function(t,n){for(var r,a=[],u=0;u<n;++u)r=u,a.push(t(r/(n-1)));return a}};"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).color=t)}.call(this);
|