@plotdb/chart 3.4.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 +30 -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/legend.js +71 -3
- package/utils/legend.min.js +1 -1
- package/utils/scale.js +228 -0
- package/utils/scale.min.js +1 -0
package/utils/brush.js
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
(function(){
|
|
2
|
+
var svgns, handleSize, brush;
|
|
3
|
+
svgns = "http://www.w3.org/2000/svg";
|
|
4
|
+
handleSize = 6;
|
|
5
|
+
brush = function(opt){
|
|
6
|
+
opt == null && (opt = {});
|
|
7
|
+
this.dir = opt.dir === 'y' ? 'y' : 'x';
|
|
8
|
+
this._extent = [[0, 0], [1, 1]];
|
|
9
|
+
this._sel = null;
|
|
10
|
+
this._g = null;
|
|
11
|
+
this.evtHandler = {};
|
|
12
|
+
return this;
|
|
13
|
+
};
|
|
14
|
+
brush.prototype = import$(Object.create(Object.prototype), {
|
|
15
|
+
on: function(n, cb){
|
|
16
|
+
var this$ = this;
|
|
17
|
+
return (Array.isArray(n)
|
|
18
|
+
? n
|
|
19
|
+
: [n]).map(function(n){
|
|
20
|
+
var ref$;
|
|
21
|
+
return ((ref$ = this$.evtHandler)[n] || (ref$[n] = [])).push(cb);
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
fire: function(n){
|
|
25
|
+
var v, res$, i$, to$, ref$, len$, cb, results$ = [];
|
|
26
|
+
res$ = [];
|
|
27
|
+
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
|
|
28
|
+
res$.push(arguments[i$]);
|
|
29
|
+
}
|
|
30
|
+
v = res$;
|
|
31
|
+
for (i$ = 0, len$ = (ref$ = this.evtHandler[n] || []).length; i$ < len$; ++i$) {
|
|
32
|
+
cb = ref$[i$];
|
|
33
|
+
results$.push(cb.apply(this, v));
|
|
34
|
+
}
|
|
35
|
+
return results$;
|
|
36
|
+
},
|
|
37
|
+
extent: function(e){
|
|
38
|
+
if (!arguments.length) {
|
|
39
|
+
return this._extent;
|
|
40
|
+
}
|
|
41
|
+
this._extent = e;
|
|
42
|
+
this._render();
|
|
43
|
+
return this;
|
|
44
|
+
},
|
|
45
|
+
selection: function(){
|
|
46
|
+
if (this._sel) {
|
|
47
|
+
return this._sel.slice();
|
|
48
|
+
} else {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
attached: function(){
|
|
53
|
+
return !!this._g;
|
|
54
|
+
},
|
|
55
|
+
_span: function(){
|
|
56
|
+
var i;
|
|
57
|
+
i = this.dir === 'x' ? 0 : 1;
|
|
58
|
+
return [this._extent[0][i], this._extent[1][i]];
|
|
59
|
+
},
|
|
60
|
+
_emit: function(type, evt){
|
|
61
|
+
return this.fire(type, {
|
|
62
|
+
type: type,
|
|
63
|
+
selection: this.selection(),
|
|
64
|
+
sourceEvent: evt || null,
|
|
65
|
+
target: this
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
move: function(sel, evt){
|
|
69
|
+
var this$ = this;
|
|
70
|
+
this._sel = sel != null ? [+sel[0], +sel[1]] : null;
|
|
71
|
+
this._render();
|
|
72
|
+
['start', 'brush', 'end'].map(function(it){
|
|
73
|
+
return this$._emit(it, evt);
|
|
74
|
+
});
|
|
75
|
+
return this;
|
|
76
|
+
},
|
|
77
|
+
clear: function(evt){
|
|
78
|
+
return this.move(null, evt);
|
|
79
|
+
},
|
|
80
|
+
attach: function(g){
|
|
81
|
+
var mk, ends, cursor, this$ = this;
|
|
82
|
+
if (this._g !== g) {
|
|
83
|
+
if (this._g) {
|
|
84
|
+
this.detach();
|
|
85
|
+
}
|
|
86
|
+
if (g.__brush && g.__brush !== this) {
|
|
87
|
+
g.__brush.detach();
|
|
88
|
+
}
|
|
89
|
+
g.__brush = this;
|
|
90
|
+
this._g = g;
|
|
91
|
+
g.setAttribute('fill', 'none');
|
|
92
|
+
g.setAttribute('pointer-events', 'all');
|
|
93
|
+
g.style.touchAction = 'none';
|
|
94
|
+
g.style.webkitTapHighlightColor = "rgba(0,0,0,0)";
|
|
95
|
+
mk = function(cls, type, attrs){
|
|
96
|
+
var n, k, v;
|
|
97
|
+
attrs == null && (attrs = {});
|
|
98
|
+
n = g.querySelector(":scope > rect." + cls.split(' ').join('.')) || g.appendChild(document.createElementNS(svgns, 'rect'));
|
|
99
|
+
n.setAttribute('class', cls);
|
|
100
|
+
n.__data__ = {
|
|
101
|
+
type: type
|
|
102
|
+
};
|
|
103
|
+
for (k in attrs) {
|
|
104
|
+
v = attrs[k];
|
|
105
|
+
n.setAttribute(k, v);
|
|
106
|
+
}
|
|
107
|
+
return n;
|
|
108
|
+
};
|
|
109
|
+
ends = this.dir === 'x'
|
|
110
|
+
? ['w', 'e']
|
|
111
|
+
: ['n', 's'];
|
|
112
|
+
cursor = this.dir === 'x' ? 'ew-resize' : 'ns-resize';
|
|
113
|
+
this._n = {
|
|
114
|
+
overlay: mk('overlay', 'overlay', {
|
|
115
|
+
"pointer-events": 'all',
|
|
116
|
+
cursor: 'crosshair'
|
|
117
|
+
}),
|
|
118
|
+
selection: mk('selection', 'selection', {
|
|
119
|
+
cursor: 'move',
|
|
120
|
+
fill: '#777',
|
|
121
|
+
"fill-opacity": 0.3,
|
|
122
|
+
stroke: '#fff',
|
|
123
|
+
"shape-rendering": 'crispEdges'
|
|
124
|
+
}),
|
|
125
|
+
handle: ends.map(function(t){
|
|
126
|
+
return mk("handle handle--" + t, t, {
|
|
127
|
+
cursor: cursor
|
|
128
|
+
});
|
|
129
|
+
})
|
|
130
|
+
};
|
|
131
|
+
g.addEventListener('pointerdown', this._down = function(e){
|
|
132
|
+
return this$._start(e);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
this._render();
|
|
136
|
+
return this;
|
|
137
|
+
},
|
|
138
|
+
detach: function(){
|
|
139
|
+
var i$, ref$, len$, n;
|
|
140
|
+
if (!this._g) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this._g.removeEventListener('pointerdown', this._down);
|
|
144
|
+
for (i$ = 0, len$ = (ref$ = [this._n.overlay, this._n.selection].concat(this._n.handle)).length; i$ < len$; ++i$) {
|
|
145
|
+
n = ref$[i$];
|
|
146
|
+
if (n.parentNode) {
|
|
147
|
+
n.parentNode.removeChild(n);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (this._g.__brush === this) {
|
|
151
|
+
this._g.__brush = null;
|
|
152
|
+
}
|
|
153
|
+
return this._g = null;
|
|
154
|
+
},
|
|
155
|
+
_render: function(){
|
|
156
|
+
var ref$, ref1$, x0, y0, x1, y1, x$, i$, len$, n, a, b, sx0, sy0, sx1, sy1, y$, h, this$ = this;
|
|
157
|
+
if (!this._g) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
ref$ = this._extent, ref1$ = ref$[0], x0 = ref1$[0], y0 = ref1$[1], ref1$ = ref$[1], x1 = ref1$[0], y1 = ref1$[1];
|
|
161
|
+
x$ = this._n.overlay;
|
|
162
|
+
x$.setAttribute('x', x0);
|
|
163
|
+
x$.setAttribute('y', y0);
|
|
164
|
+
x$.setAttribute('width', x1 - x0);
|
|
165
|
+
x$.setAttribute('height', y1 - y0);
|
|
166
|
+
if (!this._sel) {
|
|
167
|
+
for (i$ = 0, len$ = (ref$ = [this._n.selection].concat(this._n.handle)).length; i$ < len$; ++i$) {
|
|
168
|
+
n = ref$[i$];
|
|
169
|
+
n.style.display = 'none';
|
|
170
|
+
['x', 'y', 'width', 'height'].map(fn$);
|
|
171
|
+
}
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
ref$ = this._sel, a = ref$[0], b = ref$[1];
|
|
175
|
+
ref$ = this.dir === 'x'
|
|
176
|
+
? [a, y0, b, y1]
|
|
177
|
+
: [x0, a, x1, b], sx0 = ref$[0], sy0 = ref$[1], sx1 = ref$[2], sy1 = ref$[3];
|
|
178
|
+
y$ = this._n.selection;
|
|
179
|
+
y$.style.display = '';
|
|
180
|
+
y$.setAttribute('x', sx0);
|
|
181
|
+
y$.setAttribute('y', sy0);
|
|
182
|
+
y$.setAttribute('width', sx1 - sx0);
|
|
183
|
+
y$.setAttribute('height', sy1 - sy0);
|
|
184
|
+
h = handleSize / 2;
|
|
185
|
+
return this._n.handle.map(function(n, i){
|
|
186
|
+
n.style.display = '';
|
|
187
|
+
if (this$.dir === 'x') {
|
|
188
|
+
n.setAttribute('x', (i ? sx1 : sx0) - h);
|
|
189
|
+
n.setAttribute('y', sy0 - h);
|
|
190
|
+
n.setAttribute('width', handleSize);
|
|
191
|
+
return n.setAttribute('height', sy1 - sy0 + handleSize);
|
|
192
|
+
} else {
|
|
193
|
+
n.setAttribute('x', sx0 - h);
|
|
194
|
+
n.setAttribute('y', (i ? sy1 : sy0) - h);
|
|
195
|
+
n.setAttribute('width', sx1 - sx0 + handleSize);
|
|
196
|
+
return n.setAttribute('height', handleSize);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
function fn$(it){
|
|
200
|
+
return n.removeAttribute(it);
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
_pos: function(e){
|
|
204
|
+
var m, p;
|
|
205
|
+
m = this._g.getScreenCTM();
|
|
206
|
+
if (!m) {
|
|
207
|
+
return 0;
|
|
208
|
+
}
|
|
209
|
+
p = new DOMPoint(e.clientX, e.clientY).matrixTransform(m.inverse());
|
|
210
|
+
if (this.dir === 'x') {
|
|
211
|
+
return p.x;
|
|
212
|
+
} else {
|
|
213
|
+
return p.y;
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
_start: function(e){
|
|
217
|
+
var type, ref$, lo, hi, clamp, p0, s0, mode, moved, upd, mv, up, this$ = this;
|
|
218
|
+
if (e.button != null && e.button !== 0) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
type = (e.target.__data__ || {}).type;
|
|
222
|
+
if (!type) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
e.stopImmediatePropagation();
|
|
226
|
+
e.preventDefault();
|
|
227
|
+
ref$ = this._span(), lo = ref$[0], hi = ref$[1];
|
|
228
|
+
clamp = function(v){
|
|
229
|
+
var ref$;
|
|
230
|
+
return (ref$ = v > lo ? v : lo) < hi ? ref$ : hi;
|
|
231
|
+
};
|
|
232
|
+
p0 = this._pos(e);
|
|
233
|
+
s0 = this._sel ? this._sel.slice() : null;
|
|
234
|
+
mode = type === 'selection'
|
|
235
|
+
? 'move'
|
|
236
|
+
: (type === 'w' || type === 'n') && s0
|
|
237
|
+
? 'lo'
|
|
238
|
+
: (type === 'e' || type === 's') && s0 ? 'hi' : 'new';
|
|
239
|
+
if (mode === 'new') {
|
|
240
|
+
p0 = clamp(p0);
|
|
241
|
+
}
|
|
242
|
+
moved = false;
|
|
243
|
+
this._emit('start', e);
|
|
244
|
+
upd = function(e){
|
|
245
|
+
var p, d, ref$, ref1$, ref2$, anchor;
|
|
246
|
+
p = this$._pos(e);
|
|
247
|
+
if (mode === 'move') {
|
|
248
|
+
d = p - p0;
|
|
249
|
+
d = (ref$ = d > (ref2$ = lo - s0[0]) ? d : ref2$) < (ref1$ = hi - s0[1]) ? ref$ : ref1$;
|
|
250
|
+
this$._sel = [s0[0] + d, s0[1] + d];
|
|
251
|
+
} else {
|
|
252
|
+
anchor = mode === 'new'
|
|
253
|
+
? p0
|
|
254
|
+
: mode === 'lo'
|
|
255
|
+
? s0[1]
|
|
256
|
+
: s0[0];
|
|
257
|
+
p = clamp(p);
|
|
258
|
+
this$._sel = [Math.min(anchor, p), Math.max(anchor, p)];
|
|
259
|
+
}
|
|
260
|
+
this$._render();
|
|
261
|
+
return this$._emit('brush', e);
|
|
262
|
+
};
|
|
263
|
+
mv = function(e){
|
|
264
|
+
moved = true;
|
|
265
|
+
return upd(e);
|
|
266
|
+
};
|
|
267
|
+
up = function(e){
|
|
268
|
+
var noclick;
|
|
269
|
+
window.removeEventListener('pointermove', mv);
|
|
270
|
+
window.removeEventListener('pointerup', up);
|
|
271
|
+
window.removeEventListener('pointercancel', up);
|
|
272
|
+
if (!moved && mode !== 'move') {
|
|
273
|
+
this$._sel = null;
|
|
274
|
+
}
|
|
275
|
+
if (this$._sel && this$._sel[0] === this$._sel[1]) {
|
|
276
|
+
this$._sel = null;
|
|
277
|
+
}
|
|
278
|
+
this$._render();
|
|
279
|
+
if (moved) {
|
|
280
|
+
noclick = function(e){
|
|
281
|
+
e.stopImmediatePropagation();
|
|
282
|
+
return e.preventDefault();
|
|
283
|
+
};
|
|
284
|
+
window.addEventListener('click', noclick, true);
|
|
285
|
+
setTimeout(function(){
|
|
286
|
+
return window.removeEventListener('click', noclick, true);
|
|
287
|
+
}, 0);
|
|
288
|
+
}
|
|
289
|
+
return this$._emit('end', e);
|
|
290
|
+
};
|
|
291
|
+
window.addEventListener('pointermove', mv);
|
|
292
|
+
window.addEventListener('pointerup', up);
|
|
293
|
+
return window.addEventListener('pointercancel', up);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
297
|
+
(chart.utils || (chart.utils = {})).brush = brush;
|
|
298
|
+
}
|
|
299
|
+
function import$(obj, src){
|
|
300
|
+
var own = {}.hasOwnProperty;
|
|
301
|
+
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
|
302
|
+
return obj;
|
|
303
|
+
}
|
|
304
|
+
}).call(this);
|
|
@@ -0,0 +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.webkitTapHighlightColor="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);
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
}).call(this);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(){var e=function(c,f){var e,i,h;return"number"==typeof c&&null==f?new Promise(function(e){return setTimeout(e,c)}):("function"==typeof f&&(c=(e=[f,c])[0],f=e[1]),f=f||{},e="object"==typeof c?[c.func,c]:[c,{delay:"object"==typeof f?f.delay||750:f}],c=e[0],f=e[1],i={},(h=function(){for(var n,t,r,e,l=this,u=[],o=0,a=arguments.length;o<a;++o)u.push(arguments[o]);return n=u,t=!1,r=h.delay.value||f.delay||750,h.delay.value=0,(e=new Promise(function(u,e){if(!t)return i.h&&h.clear(),i.res=u,i.rej=e,i.h=setTimeout(function(){var e=c.apply(l,n);return e&&"function"==typeof e.then?e.then(function(){for(var e,n=[],t=0,r=arguments.length;t<r;++t)n.push(arguments[t]);return e=n,u.apply(null,e)}):u(e),i.res=null,i.rej=null,i.h=0,i},r)})).now=function(){return t=!0,h.clear(),c.apply(l,n)},e.cancel=function(){return h.clear()},e}).clear=function(){return clearTimeout(i.h),i.res&&i.res(null),i.h=0,i.res=null,i.rej=null,i},h.delay=function(e){return h.delay.value=e,h},h)};"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).debounce=e)}.call(this);
|