vega-dataflow
Advanced tools
Comparing version 2.0.0-beta.31 to 2.0.0
@@ -1,2 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-util"),require("vega-loader"),require("vega-statistics"),require("d3-array")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-loader","vega-statistics","d3-array"],e):e(t.vega=t.vega||{},t.vega,t.vega,t.vega,t.d3)}(this,function(t,e,i,n,r){"use strict";function a(t){var i=t||e.identity,n=[],r={};return n.add=function(t){var e=i(t);return r[e]||(r[e]=1,n.push(t)),n},n.remove=function(t){var e,a=i(t);return r[a]&&(r[a]=0,(e=n.indexOf(t))>=0&&n.splice(e,1)),n},n}function s(t){return t._id}function u(t){var e=t===Object(t)?t:{data:t};return e._id||(e._id=++Kt),e}function o(t){return u(l(t,{}))}function l(t,e){for(var i in t)"_id"!==i&&(e[i]=t[i]);return e}function d(t,e){return e._id=t._id,e}function h(t){return t&&t.constructor===f}function f(){var t=[],i=[],n=[],r=[],a=[],s=!1;return{constructor:f,insert:function(i){for(var n=e.array(i),r=0,a=n.length;r<a;++r)t.push(n[r]);return this},remove:function(t){for(var n=e.isFunction(t)?r:i,a=e.array(t),s=0,u=a.length;s<u;++s)n.push(a[s]);return this},modify:function(t,i,r){var s={field:i,value:e.constant(r)};return e.isFunction(t)?(s.filter=t,a.push(s)):(s.tuple=t,n.push(s)),this},encode:function(t,i){return e.isFunction(t)?a.push({filter:t,field:i}):n.push({tuple:t,field:i}),this},reflow:function(){return s=!0,this},pulse:function(e,o){function l(t,i,n){n?t[i]=n(t):e.encode=i,s||(d[t._id]=t)}var d,h,f,c,m,p,v;for(h=0,f=t.length;h<f;++h)e.add.push(u(t[h]));for(d={},h=0,f=i.length;h<f;++h)p=i[h],d[p._id]=p;for(h=0,f=r.length;h<f;++h)m=r[h],o.forEach(function(t){m(t)&&(d[t._id]=t)});for(v in d)e.rem.push(d[v]);for(d={},h=0,f=n.length;h<f;++h)c=n[h],l(c.tuple,c.field,c.value),e.modifies(c.field);for(h=0,f=a.length;h<f;++h)c=a[h],m=c.filter,o.forEach(function(t){m(t)&&l(t,c.field,c.value)}),e.modifies(c.field);if(s)e.mod=i.length||r.length?o.filter(function(t){return d.hasOwnProperty(t._id)}):o.slice();else for(v in d)e.mod.push(d[v]);return e}}}function c(){Object.defineProperty(this,Vt,{writable:!0,value:{}})}function m(t,e,i,n){this.id=++Jt,this.value=t,this.stamp=-1,this.rank=-1,this.qrank=-1,this.flags=0,e&&(this._update=e),i&&this.parameters(i,n)}function p(t){return function(e){var i=this.flags;return 0===arguments.length?!!(i&t):(this.flags=e?i|t:i&~t,this)}}function v(t,e,i){this.id=++ee,this.value=null,i&&(this.receive=i),t&&(this._filter=t),e&&(this._apply=e)}function g(t,e,i){return new v(t,e,i)}function _(t,i,n,r,a,s){var u,o,l=e.extend({},s,re);e.isFunction(n)||(n=e.constant(n)),void 0===r?u=function(e){t.touch(n(e))}:e.isFunction(r)?(o=new m(null,r,a,!1),u=function(e){var i=n(e),r=(o.evaluate(e),o.value);h(r)?t.pulse(i,r,s):t.update(i,r,l)}):u=function(e){t.update(n(e),r,l)},i.apply(u)}function y(t,i,n,r,a,s){var u,o;void 0===r?o=n:(u=e.isFunction(r)?r:e.constant(r),r=n?function(t,e){var i=u(t,e);return n.skip()?i:n.skip(!0).value=i}:u,o=new m(null,r,a,!1),o.modified(s&&s.force),o.rank=0,n&&(o.skip(!0),o.value=n.value,o.targets().add(n))),i.targets().add(o)}function x(t){t.rank=++this._rank}function k(t){for(var e,i,n,r=[t];r.length;)if(this.rank(e=r.pop()),i=e._targets)for(n=i.length;--n>=0;)r.push(e=i[n]),e===t&&this.error("Cycle detected in dataflow graph.")}function w(t,e,i){this.dataflow=t,this.stamp=null==e?-1:e,this.add=[],this.rem=[],this.mod=[],this.fields=null,this.encode=i||null}function D(t,e){return t?function(i,n){return t(i,n)&&e(i,n)}:e}function O(t,e){var i={};return t.visit(e,function(t){i[t._id]=1}),function(t){return i[t._id]?null:t}}function q(t,e){var i=e||_e;return this._pulse?this._enqueue(t):this._touched.add(t),i.skip&&t.skip(!0),this}function b(t,e,i){var n=i||_e;return(t.set(e)||n.force)&&this.touch(t,n),this}function E(t,e,i){this.touch(t,i||_e);var n=new w(this,this._clock+(this._pulse?0:1));return n.target=t,this._pulses[t.id]=e.pulse(n,t.value),this}function F(t,e,n){return this.pulse(t,this.changeset().insert(i.read(e,n)))}function A(t){var e,i,n=new Promise(function(t,n){e=t,i=n});return n.requests=0,n.done=function(){0===--n.requests&&t.runAfter(function(){t._pending=null;try{t.run(),e(t)}catch(t){i(t)}})},t._pending=n}function R(t,e,i){var n=this,r=n._pending||A(n);r.requests+=1,n.loader().load(e,{context:"dataflow"}).then(function(e){n.ingest(t,e,i)},function(t){n.warn("Loading failed: "+e,t),r.done()}).then(r.done).catch(function(t){n.warn(t)})}function M(t,e,i,n){var r,a,s,u,o,l=this,d=0;for(this.dataflow=t,this.stamp=e,this.fields=null,this.encode=n||null,this.pulses=i,s=0,u=i.length;s<u;++s)if(r=i[s],r.stamp===e){if(r.fields){a=l.fields||(l.fields={});for(o in r.fields)a[o]=1}r.changed(l.ADD)&&(d|=l.ADD),r.changed(l.REM)&&(d|=l.REM),r.changed(l.MOD)&&(d|=l.MOD)}this.changes=d}function S(t){if(!this._touched.length)return 0;if(this._pending)return this.info("Awaiting requests, delaying dataflow run."),0;var i,n,r,s=this,u=0,o=s.logLevel();s._pulse=new w(s,++s._clock,t),o>=e.Info&&(r=Date.now(),s.debug("-- START PROPAGATION ("+s._clock+") -----")),s._touched.forEach(function(t){s._enqueue(t,!0)}),s._touched=a(e.id);try{for(;s._heap.size()>0;)i=s._heap.pop(),i.rank===i.qrank?(n=i.run(s._getPulse(i,t)),o>=e.Debug&&s.debug(i.id,n===se?"STOP":n,i),n!==se&&(s._pulse=n,i._targets&&i._targets.forEach(function(t){s._enqueue(t)})),++u):s._enqueue(i,!0)}catch(t){s.error(t)}if(s._pulses={},s._pulse=null,o>=e.Info&&(r=Date.now()-r,s.info("> Pulse "+s._clock+": "+u+" operators; "+r+"ms")),s._postrun.length){var l=s._postrun;s._postrun=[],l.forEach(function(t){try{t(s)}catch(t){s.error(t)}})}return u}function N(){return this._pending||Promise.resolve(this.run())}function C(t){if(this._pulse)this._postrun.push(t);else try{t(this)}catch(t){this.error(t)}}function P(t,e){var i=!this._pulses[t.id];i&&(this._pulses[t.id]=this._pulse),(i||e)&&(t.qrank=t.rank,this._heap.push(t))}function U(t,i){var n,r=t.source,a=this._clock;return r&&e.isArray(r)?(n=r.map(function(t){return t.pulse}),new M(this,a,n,i)):(r=r&&r.pulse,n=this._pulses[t.id],r&&r!==se&&(r.stamp===a&&n.target!==t?n=r:n.source=r.source),n)}function L(t){this.cmp=t,this.nodes=[]}function z(t,e,i,n){var r,a,s;for(r=t[i];i>e&&(s=i-1>>1,a=t[s],n(r,a)<0);)t[i]=a,i=s;return t[i]=r}function I(t,e,i){for(var n,r=e,a=t.length,s=t[e],u=2*e+1;u<a;)n=u+1,n<a&&i(t[u],t[n])>=0&&(u=n),t[e]=t[u],e=u,u=2*e+1;return t[e]=s,z(t,r,e,i)}function T(){this._log=e.logger(),this._clock=0,this._rank=0,this._loader=i.loader(),this._touched=a(e.id),this._pulses={},this._pulse=null,this._heap=new L(function(t,e){return t.qrank-e.qrank}),this._postrun=[]}function j(t){return function(){return this._log[t].apply(this,arguments)}}function W(t,e){m.call(this,t,null,e)}function G(t,e){var i=t.type;K(i,t),V(i,e)}function K(t,e){return t=t&&t.toLowerCase(),arguments.length>1?(Oe[t]=e,this):Oe.hasOwnProperty(t)?Oe[t]:null}function V(t,e){return arguments.length>1?(De[t]=e,this):De.hasOwnProperty(t)?De[t]:null}function B(t){this._key=t||"_id",this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null}function J(t,e){return be[t](e)}function $(t){return function(i){var n=e.extend({init:"",add:"",rem:"",idx:0},t);return n.out=i||t.name,n}}function H(t,e){return t.idx-e.idx}function Q(t,e){function i(t,n){function r(e){t[e]||i(t,t[e]=be[e]())}return n.req&&n.req.forEach(r),e&&n.str&&n.str.forEach(r),t}var n,r=t.reduce(i,t.reduce(function(t,e){return t[e.name]=e,t},{})),a=[];for(n in r)a.push(r[n]);return a.sort(H)}function X(t,i){var n=i||e.identity,r=Q(t,!0),a="this.cell = cell; this.tuple = t; this.valid = 0; this.missing = 0;",s="if(v==null){++this.missing; return;} if(v!==v) return; ++this.valid;",u="if(v==null){--this.missing; return;} if(v!==v) return; --this.valid;",o="var t = this.tuple; var cell = this.cell;";return r.forEach(function(t){t.idx<0?(a=t.init+a,s=t.add+s,u=t.rem+u):(a+=t.init,s+=t.add,u+=t.rem)}),t.slice().sort(H).forEach(function(t){o+="t['"+t.out+"']="+t.set+";"}),o+="return t;",a=Function("cell","t",a),a.prototype.add=Function("v","t",s),a.prototype.rem=Function("v","t",u),a.prototype.set=Function(o),a.prototype.get=n,a.fields=t.map(function(t){return t.out}),a}function Y(t){W.call(this,null,t),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._cross=!1,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}function Z(t,e,i){return i||t+(e?"_"+e:"")}function tt(t){var e,i=this._dims,n=i.length,r=String(i[0](t));for(e=1;e<n;++e)r+="|"+i[e](t);return r}function et(t){W.call(this,null,t)}function it(t){W.call(this,[],t)}function nt(t){m.call(this,null,rt,t)}function rt(t){return this.value&&!t.modified()?this.value:e.compare(t.fields,t.orders)}function at(t){W.call(this,null,t)}function st(t,e,i){switch(e){case"upper":t=t.toUpperCase();break;case"lower":t=t.toLowerCase()}return t.match(i)}function ut(t){W.call(this,null,t)}function ot(t,e,i,n){for(var r,a,s=[],o={},l=t.length,d=0;d<l;++d)for(o[e]=a=t[d],r=0;r<l;++r)o[i]=t[r],n(o)&&(s.push(u(o)),o={},o[e]=a);return s}function lt(t,i){var n=t[Ce];Se.hasOwnProperty(n)||e.error("Unknown distribution function: "+n);var r=Se[n]();for(var a in t)a===Pe?r.data((t.from||i()).map(t[a])):a===Ne?r[a](t[a].map(function(t){return lt(t,i)})):typeof r[a]===Ce&&r[a](t[a]);return r}function dt(t){W.call(this,null,t)}function ht(t){return function(){return t.materialize(t.SOURCE).source}}function ft(t){W.call(this,[+(1/0),-(1/0)],t)}function ct(t,e){m.call(this,t),this.parent=e}function mt(t){W.call(this,{},t),this._keys=e.fastmap();var i=this._targets=[];i.active=0,i.forEach=function(t){for(var e=0,n=i.active;e<n;++e)t(i[e],e,i)}}function pt(t){m.call(this,null,vt,t)}function vt(t){return this.value&&!t.modified()?this.value:e.isArray(t.name)?e.array(t.name).map(function(t){return e.field(t)}):e.field(t.name,t.as)}function gt(t){W.call(this,e.fastmap(),t)}function _t(t){W.call(this,{},t)}function yt(t){return t.fields.join("|")}function xt(t){W.call(this,null,t)}function kt(t){W.call(this,[],t)}function wt(t){W.call(this,[],t)}function Dt(t){var i,n=t.method||Ke.value;return null!=Ke[n]?n===Ke.value?(i=void 0!==t.value?t.value:0,function(){return i}):Ke[n]:void e.error("Unrecognized imputation method: "+n)}function Ot(t){var e=t.field;return function(t){return t?e(t):NaN}}function qt(t,e,i){var n,r,a,s,u,o,l,d,h,f=function(t){return t(h)},c=[],m=[],p={},v={};for(o=0,d=t.length;o<d;++o)h=t[o],r=(n=i.map(f))+"",l=p[r]||(p[r]=m.push(n)),s=(a=e?e.map(f):Ve)+"",(u=v[s])||(u=v[s]=[],c.push(u),u.values=a),u[l-1]=h;return c.domain=m,c}function bt(t){Y.call(this,t)}function Et(t){m.call(this,null,Ft,t)}function Ft(t){return this.value&&!t.modified()?this.value:e.key(t.fields)}function At(t){W.call(this,{},t)}function Rt(t){m.call(this,null,Mt,t)}function Mt(t){if(this.value&&!t.modified())return this.value;var e,i,n,r=+(1/0),a=-(1/0),s=t.extents;for(e=0,i=s.length;e<i;++e)n=s[e],n[0]<r&&(r=n[0]),n[1]>a&&(a=n[1]);return[r,a]}function St(t){m.call(this,null,Nt,t)}function Nt(t){return this.value&&!t.modified()?this.value:t.values.reduce(function(t,e){return t.concat(e)},[])}function Ct(t){W.call(this,null,t)}function Pt(t){mt.call(this,t)}function Ut(t){W.call(this,null,t)}function Lt(t){W.call(this,null,t)}function zt(t){W.call(this,null,t)}function It(t){W.call(this,[],t),this.count=0}function Tt(t){W.call(this,null,t)}function jt(t){W.call(this,null,t),this.modified(!0)}function Wt(t){W.call(this,e.fastmap(),t)}function Gt(t){W.call(this,null,t)}var Kt=1,Vt="_:mod:_",Bt=c.prototype;Bt.set=function(t,i,n,r){var a=this,s=a[t],u=a[Vt];return null!=i&&i>=0?(s[i]!==n||r)&&(s[i]=n,u[i+":"+t]=-1,u[t]=-1):(s!==n||r)&&(a[t]=n,u[t]=e.isArray(n)?1+n.length:-1),a},Bt.modified=function(t,i){var n,r=this[Vt];if(!arguments.length){for(n in r)if(r[n])return!0;return!1}if(e.isArray(t)){for(n=0;n<t.length;++n)if(r[t[n]])return!0;return!1}return null!=i&&i>=0?i+1<r[t]||!!r[i+":"+t]:!!r[t]},Bt.clear=function(){return this[Vt]={},this};var Jt=0,$t="pulse",Ht=new c,Qt=1,Xt=2,Yt=m.prototype;Yt.targets=function(){return this._targets||(this._targets=a(e.id))},Yt.set=function(t){return this.value!==t?(this.value=t,1):0},Yt.skip=p(Qt),Yt.modified=p(Xt),Yt.parameters=function(t,i){function n(t,e,n){n instanceof m?(n!==o&&(i&&n.targets().add(o),h.push(n)),d.push({op:n,name:t,index:e})):l.set(t,e,n)}i=i!==!1;var r,a,s,u,o=this,l=o._argval=o._argval||new c,d=o._argops=o._argops||[],h=[];for(r in t)if(a=t[r],r===$t)e.array(a).forEach(function(t){t instanceof m?t!==o&&(t.targets().add(o),h.push(t)):e.error("Pulse parameters must be operator instances.")}),o.source=a;else if(e.isArray(a))for(l.set(r,-1,Array(s=a.length)),u=0;u<s;++u)n(r,u,a[u]);else n(r,-1,a);return this.marshall().clear(),h},Yt.marshall=function(t){var e,i,n,r,a,s=this._argval||Ht,u=this._argops;if(u&&(n=u.length))for(i=0;i<n;++i)e=u[i],r=e.op,a=r.modified()&&r.stamp===t,s.set(e.name,e.index,r.value,a);return s},Yt.evaluate=function(t){if(this._update){var e=this.marshall(t.stamp),i=this._update(e,t);if(e.clear(),i!==this.value)this.value=i;else if(!this.modified())return t.StopPropagation}},Yt.run=function(t){if(t.stamp<=this.stamp)return t.StopPropagation;var e=this.skip()?(this.skip(!1),0):this.evaluate(t);return this.stamp=t.stamp,this.pulse=e||t};var Zt=function(t,i,n,r){var a=1,s=t instanceof m?t:t&&t.prototype instanceof m?new t:e.isFunction(t)?new m(null,t):(a=0,new m(t,i));return this.rank(s),a&&(r=n,n=i),n&&this.connect(s,s.parameters(n,r)),this.touch(s),s},te=function(t,e){var i,n,r=t.rank;for(i=0,n=e.length;i<n;++i)if(r<e[i].rank)return void this.rerank(t)},ee=0,ie=v.prototype;ie._filter=e.truthy,ie._apply=e.identity,ie.targets=function(){return this._targets||(this._targets=a(e.id))},ie.consume=function(t){return arguments.length?(this._consume=!!t,this):!!this._consume},ie.receive=function(t){if(this._filter(t)){for(var e=this.value=this._apply(t),i=this._targets,n=i?i.length:0,r=0;r<n;++r)i[r].receive(e);this._consume&&(t.preventDefault(),t.stopPropagation())}},ie.filter=function(t){var e=g(t);return this.targets().add(e),e},ie.apply=function(t){var e=g(null,t);return this.targets().add(e),e},ie.merge=function(){var t=g();this.targets().add(t);for(var e=0,i=arguments.length;e<i;++e)arguments[e].targets().add(t);return t},ie.throttle=function(t){var e=-1;return this.filter(function(){var i=Date.now();return i-e>t?(e=i,1):0})},ie.debounce=function(t){var i=g();return this.targets().add(g(null,null,e.debounce(t,function(t){var e=t.dataflow;i.receive(t),e&&e.run&&e.run()}))),i},ie.between=function(t,e){var i=!1;return t.targets().add(g(null,null,function(){i=!0})),e.targets().add(g(null,null,function(){i=!1})),this.filter(function(){return i})};var ne=function(t,i,n,r){var a,s=this,u=g(n,r),o=function(t){t.dataflow=s,u.receive(t),s.run()};a="string"==typeof t&&"undefined"!=typeof document?document.querySelectorAll(t):e.array(t);for(var l=0,d=a.length;l<d;++l)a[l].addEventListener(i,o);return u},re={skip:!0},ae=function(t,e,i,n,r){var a=t instanceof m?y:_;return a(this,t,e,i,n,r),this},se={},ue=1,oe=2,le=4,de=ue|oe,he=ue|le,fe=ue|oe|le,ce=8,me=16,pe=32,ve=64,ge=w.prototype;ge.StopPropagation=se,ge.ADD=ue,ge.REM=oe,ge.MOD=le,ge.ADD_REM=de,ge.ADD_MOD=he,ge.ALL=fe,ge.REFLOW=ce,ge.SOURCE=me,ge.NO_SOURCE=pe,ge.NO_FIELDS=ve,ge.fork=function(t){return new w(this.dataflow).init(this,t)},ge.addAll=function(){var t=this;return this.source&&this.source.length!==this.add.length?(t=new w(this.dataflow).init(this),t.add=t.source,t):t},ge.init=function(t,e){var i=this;return i.stamp=t.stamp,i.encode=t.encode,!t.fields||e&ve||(i.fields=t.fields),i.add=e&ue?(i.addF=t.addF,t.add):(i.addF=null,[]),i.rem=e&oe?(i.remF=t.remF,t.rem):(i.remF=null,[]),i.mod=e&le?(i.modF=t.modF,t.mod):(i.modF=null,[]),i.source=e&pe?(i.srcF=null,null):(i.srcF=t.srcF,t.source),i},ge.runAfter=function(t){this.dataflow.runAfter(t)},ge.changed=function(t){var e=t||fe;return e&ue&&this.add.length||e&oe&&this.rem.length||e&le&&this.mod.length},ge.reflow=function(t){if(t)return this.fork(fe).reflow();var e=this.add.length,i=this.source&&this.source.length;return i&&i!==e&&(this.mod=this.source,e&&this.filter(le,O(this,ue))),this},ge.modifies=function(t){var i=e.array(t),n=this.fields||(this.fields={});return i.forEach(function(t){n[t]=!0}),this},ge.modified=function(t){var i=this.fields;return!(!this.mod.length||!i)&&(arguments.length?e.isArray(t)?t.some(function(t){return i[t]}):i[t]:!!i)},ge.filter=function(t,e){var i=this;return t&ue&&(i.addF=D(i.addF,e)),t&oe&&(i.remF=D(i.remF,e)),t&le&&(i.modF=D(i.modF,e)),t&me&&(i.srcF=D(i.srcF,e)),i},ge.materialize=function(t){t=t||fe;var e=this;return t&ue&&e.addF&&(e.add=e.add.filter(e.addF),e.addF=null),t&oe&&e.remF&&(e.rem=e.rem.filter(e.remF),e.remF=null),t&le&&e.modF&&(e.mod=e.mod.filter(e.modF),e.modF=null),t&me&&e.srcF&&(e.source=e.source.filter(e.srcF),e.srcF=null),e},ge.visit=function(t,i){var n,r,a=i;return t&me?(e.visitArray(this.source,this.srcF,a),this):(t&ue&&e.visitArray(this.add,this.addF,a),t&oe&&e.visitArray(this.rem,this.remF,a),t&le&&e.visitArray(this.mod,this.modF,a),t&ce&&(n=this.source)&&(r=this.add.length+this.mod.length,r===n.length||(r?e.visitArray(n,O(this,he),a):e.visitArray(n,this.srcF,a))),this)};var _e={skip:!1,force:!1},ye=e.inherits(M,w);ye.fork=function(){return arguments.length&&arguments[0]&w.prototype.ALL&&e.error("MultiPulse fork does not support tuple change sets."),new w(this.dataflow).init(this,0)},ye.changed=function(t){return this.changes&t},ye.modified=function(t){var i=this,n=i.fields;return n&&i.changes&i.MOD?e.isArray(t)?t.some(function(t){return n[t]}):n[t]:0},ye.filter=function(){e.error("MultiPulse does not support filtering.")},ye.materialize=function(){e.error("MultiPulse does not support materialization.")},ye.visit=function(t,e){var i=this,n=i.pulses,r=n.length,a=0;if(t&i.SOURCE)for(;a<r;++a)n[a].visit(t,e);else for(;a<r;++a)n[a].stamp===i.stamp&&n[a].visit(t,e);return i};var xe=L.prototype;xe.size=function(){return this.nodes.length},xe.clear=function(){return this.nodes=[],this},xe.peek=function(){return this.nodes[0]},xe.push=function(t){var e=this.nodes;return e.push(t),z(e,0,e.length-1,this.cmp)},xe.pop=function(){var t,e=this.nodes,i=e.pop();return e.length?(t=e[0],e[0]=i,I(e,0,this.cmp)):t=i,t},xe.replace=function(t){var e=this.nodes,i=e[0];return e[0]=t,I(e,0,this.cmp),i},xe.pushpop=function(t){var e=this.nodes,i=e[0];return e.length&&this.cmp(i,t)<0&&(e[0]=t,t=i,I(e,0,this.cmp)),t};var ke=T.prototype;ke.stamp=function(){return this._clock},ke.loader=function(t){return arguments.length?(this._loader=t,this):this._loader},ke.cleanThreshold=1e4,ke.add=Zt,ke.connect=te,ke.rank=x,ke.rerank=k,ke.pulse=E,ke.touch=q,ke.update=b,ke.changeset=f,ke.ingest=F,ke.request=R,ke.events=ne,ke.on=ae,ke.run=S,ke.runAsync=N,ke.runAfter=C,ke._enqueue=P,ke._getPulse=U,ke.warn=j("warn"),ke.info=j("info"),ke.debug=j("debug"),ke.logLevel=j("level"),ke.error=function(t){throw t};var we=e.inherits(W,m);we.run=function(t){if(t.stamp<=this.stamp)return t.StopPropagation;var e=(this.skip()?(this.skip(!1),0):this.evaluate(t))||t;return e!==t.StopPropagation&&(this.pulse=e),this.stamp=t.stamp,e},we.evaluate=function(t){var e=this.marshall(t.stamp),i=this.transform(e,t);return e.clear(),i},we.transform=function(){};var De={},Oe={},qe=B.prototype;qe.add=function(t){this._add.push(t)},qe.rem=function(t){this._rem.push(t)},qe.values=function(){if(this._get=null,0===this._rem.length)return this._add;var t,e,i,n=this._add,r=this._rem,a=this._key,s=n.length,u=r.length,o=Array(s-u),l={};for(t=0;t<u;++t)l[r[t][a]]=1;for(t=0,e=0;t<s;++t)l[(i=n[t])[a]]?l[i[a]]=0:o[e++]=i;return this._rem=[],this._add=o},qe.distinct=function(t){for(var e,i=this.values(),n=i.length,r={},a=0;--n>=0;)e=t(i[n])+"",r.hasOwnProperty(e)||(r[e]=1,++a);return a},qe.extent=function(t){if(this._get!==t||!this._ext){var i=this.values(),n=e.extentIndex(i,t);this._ext=[i[n[0]],i[n[1]]],this._get=t}return this._ext},qe.argmin=function(t){return this.extent(t)[0]||{}},qe.argmax=function(t){return this.extent(t)[1]||{}},qe.min=function(t){var e=this.extent(t)[0];return null!=e?t(e):+(1/0)},qe.max=function(t){var e=this.extent(t)[1];return null!=e?t(e):-(1/0)},qe.quartile=function(t){return this._get===t&&this._q||(this._q=n.quartiles(this.values(),t),this._get=t),this._q},qe.q1=function(t){return this.quartile(t)[0]},qe.q2=function(t){return this.quartile(t)[1]},qe.q3=function(t){return this.quartile(t)[2]},qe.ci=function(t){return this._get===t&&this._ci||(this._ci=n.bootstrapCI(this.values(),1e3,.05,t),this._get=t),this._ci},qe.ci0=function(t){return this.ci(t)[0]},qe.ci1=function(t){return this.ci(t)[1]};var be={values:$({name:"values",init:"cell.store = true;",set:"cell.data.values()",idx:-1}),count:$({name:"count",set:"cell.num"}),missing:$({name:"missing",set:"this.missing"}),valid:$({name:"valid",set:"this.valid"}),sum:$({name:"sum",init:"this.sum = 0;",add:"this.sum += v;",rem:"this.sum -= v;",set:"this.sum"}),mean:$({name:"mean",init:"this.mean = 0;",add:"var d = v - this.mean; this.mean += d / this.valid;",rem:"var d = v - this.mean; this.mean -= this.valid ? d / this.valid : this.mean;",set:"this.mean"}),average:$({name:"average",set:"this.mean",req:["mean"],idx:1}),variance:$({name:"variance",init:"this.dev = 0;",add:"this.dev += d * (v - this.mean);",rem:"this.dev -= d * (v - this.mean);",set:"this.valid > 1 ? this.dev / (this.valid-1) : 0",req:["mean"],idx:1}),variancep:$({name:"variancep",set:"this.valid > 1 ? this.dev / this.valid : 0",req:["variance"],idx:2}),stdev:$({name:"stdev",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid-1)) : 0",req:["variance"],idx:2}),stdevp:$({name:"stdevp",set:"this.valid > 1 ? Math.sqrt(this.dev / this.valid) : 0",req:["variance"],idx:2}),stderr:$({name:"stderr",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid * (this.valid-1))) : 0",req:["variance"],idx:2}),distinct:$({name:"distinct",set:"cell.data.distinct(this.get)",req:["values"],idx:3}),ci0:$({name:"ci0",set:"cell.data.ci0(this.get)",req:["values"],idx:3}),ci1:$({name:"ci1",set:"cell.data.ci1(this.get)",req:["values"],idx:3}),median:$({name:"median",set:"cell.data.q2(this.get)",req:["values"],idx:3}),q1:$({name:"q1",set:"cell.data.q1(this.get)",req:["values"],idx:3}),q3:$({name:"q3",set:"cell.data.q3(this.get)",req:["values"],idx:3}),argmin:$({name:"argmin",add:"if (v < this.min) this.argmin = t;",rem:"if (v <= this.min) this.argmin = null;",set:"this.argmin || cell.data.argmin(this.get)",req:["min"],str:["values"],idx:3}),argmax:$({name:"argmax",add:"if (v > this.max) this.argmax = t;",rem:"if (v >= this.max) this.argmax = null;",set:"this.argmax || cell.data.argmax(this.get)",req:["max"],str:["values"],idx:3}),min:$({name:"min",init:"this.min = null;",add:"if (v < this.min || this.min === null) this.min = v;",rem:"if (v <= this.min) this.min = NaN;",set:"this.min = (isNaN(this.min) ? cell.data.min(this.get) : this.min)",str:["values"],idx:4}),max:$({name:"max",init:"this.max = null;",add:"if (v > this.max || this.max === null) this.max = v;",rem:"if (v >= this.max) this.max = NaN;",set:"this.max = (isNaN(this.max) ? cell.data.max(this.get) : this.max)",str:["values"],idx:4})},Ee=e.inherits(Y,W);Ee.transform=function(t,e){var i,n=this,r=e.fork(e.NO_SOURCE|e.NO_FIELDS);return this.stamp=r.stamp,this.value&&((i=t.modified())||e.modified(this._inputs))?(this._prev=this.value,this.value=i?this.init(t):{},e.visit(e.SOURCE,function(t){n.add(t)})):(this.value=this.value||this.init(t),e.visit(e.REM,function(t){n.rem(t)}),e.visit(e.ADD,function(t){n.add(t)})),r.modifies(this._outputs),n._drop=t.drop!==!1,t.cross&&n._dims.length>1&&(n._drop=!1,this.cross()),n.changes(r)},Ee.cross=function(){function t(t){var e,i,n,u;for(e in t)for(n=t[e].tuple,i=0;i<s;++i)a[i][u=n[r[i]]]=u}function e(t,u,o){var l,d,h=r[o],f=a[o++];for(l in f)u[h]=f[l],d=t?t+"|"+l:l,o<s?e(d,u,o):n[d]||i.cell(d,u)}var i=this,n=i.value,r=i._dnames,a=r.map(function(){return{}}),s=r.length;t(i._prev),t(n),e("",{},0)},Ee.init=function(t){function i(t){for(var e,i=t.fields,r=0,s=i.length;r<s;++r)a[e=i[r]]||(a[e]=1,n.push(e))}var n=this._inputs=[],r=this._outputs=[],a={};this._dims=e.array(t.groupby),this._dnames=this._dims.map(function(t){var n=e.accessorName(t);return i(t),r.push(n),n}),this.cellkey=t.key?t.key:0===this._dims.length?function(){return""}:1===this._dims.length?this._dims[0]:tt,this._countOnly=!0,this._counts=[],this._measures=[];var s,u,o,l,d,h,f=t.fields||[null],c=t.ops||["count"],m=t.as||[],p=f.length,v={};for(p!==c.length&&e.error("Unmatched number of fields and aggregate ops."),h=0;h<p;++h)s=f[h],u=c[h],null==s&&"count"!==u&&e.error("Null aggregate field specified."),l=e.accessorName(s),d=Z(u,l,m[h]),r.push(d),"count"!==u?(o=v[l],o||(i(s),o=v[l]=[],o.field=s,this._measures.push(o)),"count"!==u&&(this._countOnly=!1),o.push(J(u,d))):this._counts.push(d);return this._measures=this._measures.map(function(t){return X(t,t.field)}),{}},Ee.cellkey=tt,Ee.cell=function(t,e){var i=this.value[t];return i?0===i.num&&this._drop&&i.stamp<this.stamp?(i.stamp=this.stamp,this._adds[this._alen++]=i):i.stamp<this.stamp&&(i.stamp=this.stamp,this._mods[this._mlen++]=i):(i=this.value[t]=this.newcell(t,e),this._adds[this._alen++]=i),i},Ee.newcell=function(t,e){var i={key:t,num:0,agg:null,tuple:this.newtuple(e,this._prev&&this._prev[t]),stamp:this.stamp,store:!1};if(!this._countOnly){var n,r=this._measures,a=r.length;for(i.agg=Array(a),n=0;n<a;++n)i.agg[n]=new r[n](i,i.tuple)}return i.store&&(i.data=new B),i},Ee.newtuple=function(t,e){var i,n,r=this._dnames,a=this._dims,s={};for(i=0,n=a.length;i<n;++i)s[r[i]]=a[i](t);return e?d(e.tuple,s):u(s)},Ee.add=function(t){var e,i,n,r=this.cellkey(t),a=this.cell(r,t);if(a.num+=1,!this._countOnly)for(a.store&&a.data.add(t),e=a.agg,i=0,n=e.length;i<n;++i)e[i].add(e[i].get(t),t)},Ee.rem=function(t){var e,i,n,r=this.cellkey(t),a=this.cell(r,t);if(a.num-=1,!this._countOnly)for(a.store&&a.data.rem(t),e=a.agg,i=0,n=e.length;i<n;++i)e[i].rem(e[i].get(t),t)},Ee.celltuple=function(t){var e,i,n,r=t.tuple,a=this._counts;for(t.store&&t.data.values(),i=0,n=a.length;i<n;++i)r[a[i]]=t.num;if(!this._countOnly)for(e=t.agg,i=0,n=e.length;i<n;++i)e[i].set();return r},Ee.changes=function(t){var e,i,n,r,a=this._adds,s=this._mods,u=this._prev,o=this._drop,l=t.add,d=t.rem,h=t.mod;if(u)for(i in u)d.push(u[i].tuple);for(n=0,r=this._alen;n<r;++n)l.push(this.celltuple(a[n])),a[n]=null;for(n=0,r=this._mlen;n<r;++n)e=s[n],(0===e.num&&o?d:h).push(this.celltuple(e)),s[n]=null;return this._alen=this._mlen=0,this._prev=null,t};var Fe=e.inherits(et,W);Fe.transform=function(t,i){var n=this._bins(t),r=n.start,a=n.step,s=t.as||["bin0","bin1"],u=s[0],o=s[1],l=t.modified()?(i=i.reflow(!0),i.SOURCE):i.modified(e.accessorFields(t.field))?i.ADD_MOD:i.ADD;return i.visit(l,function(t){var e=n(t);t[u]=e,t[o]=null==e?null:r+a*(1+(e-r)/a)}),i.modifies(s)},Fe._bins=function(t){if(this.value&&!t.modified())return this.value;var i,r,a=t.field,s=n.bin(t),u=s.start,o=s.stop,l=s.step;null!=(i=t.anchor)&&(r=i-(u+l*Math.floor((i-u)/l)),u+=r,o+=r);var d=function(t){var e=a(t);return null==e?null:(e=Math.max(u,Math.min(+e,o-l)),u+l*Math.floor((e-u)/l))};return d.start=u,d.stop=o,d.step=l,this.value=e.accessor(d,e.accessorFields(a),t.name||"bin_"+e.accessorName(a))};var Ae=e.inherits(it,W);Ae.transform=function(t,i){var n,r=i.fork(i.ALL),a=i.changed(i.ADD),s=i.changed(),u=t.sort,o=this.value,l=function(t){o.push(t)},d=0;return r.rem.length&&(n={},r.visit(r.REM,function(t){n[t._id]=1,++d}),o=o.filter(function(t){return!n[t._id]})),u?((t.modified("sort")||i.modified(u.fields))&&(o.sort(u),s=!0),a&&(o=e.merge(u,o,r.add.sort(u)))):a&&r.visit(r.ADD,l),this.modified(s),this.value=r.source=o,r},e.inherits(nt,m);var Re=e.inherits(at,W);Re.transform=function(t,e){function i(e){return function(i){for(var n,r=st(u(i),t.case,a)||[],o=0,l=r.length;o<l;++o)s.test(n=r[o])||e(n)}}var n=this._parameterCheck(t,e),r=this._counts,a=this._match,s=this._stop,u=t.field,o=t.as||["text","count"],l=i(function(t){r[t]=1+(r[t]||0)}),d=i(function(t){r[t]-=1});return n?e.visit(e.SOURCE,l):(e.visit(e.ADD,l),e.visit(e.REM,d)),this._finish(e,o)},Re._parameterCheck=function(t,e){var i=!1;return!t.modified("stopwords")&&this._stop||(this._stop=new RegExp("^"+(t.stopwords||"")+"$","i"),i=!0),!t.modified("pattern")&&this._match||(this._match=new RegExp(t.pattern||"[\\w']+","g"),i=!0),(t.modified("field")||e.modified(t.field.fields))&&(i=!0),i&&(this._counts={}),i},Re._finish=function(t,e){var i,n,r,a=this._counts,s=this._tuples||(this._tuples={}),o=e[0],l=e[1],d=t.fork();for(i in a)n=s[i],r=a[i]||0,!n&&r?(s[i]=n=u({}),n[o]=i,n[l]=r,d.add.push(n)):0===r?(n&&d.rem.push(n),a[i]=null,s[i]=null):n[l]!==r&&(n[l]=r,d.mod.push(n));return d.modifies(e)};var Me=e.inherits(ut,W);Me.transform=function(t,i){var n=i.fork(i.NO_SOURCE),r=this.value,a=t.as||["a","b"],s=a[0],u=a[1],o=!r||i.changed(i.ADD_REM)||t.modified("as")||t.modified("filter");return o?(r&&(n.rem=r),n.add=this.value=ot(i.source,s,u,t.filter||e.truthy)):n.mod=r,n.source=this.value,n.modifies(a)};var Se={kde:n.randomKDE,mixture:n.randomMixture,normal:n.randomNormal,uniform:n.randomUniform},Ne="distributions",Ce="function",Pe="field",Ue=e.inherits(dt,W);Ue.transform=function(t,i){var n=i.fork(i.NO_SOURCE|i.NO_FIELDS);if(!this.value||i.changed()||t.modified()){var a=lt(t.distribution,ht(i)),s=t.method||"pdf";"pdf"!==s&&"cdf"!==s&&e.error("Invalid density method: "+s),t.extent||a.data||e.error("Missing density extent parameter."),s=a[s];var o=t.as||["value","density"],l=t.extent||r.extent(a.data()),d=(l[1]-l[0])/(t.steps||100),h=r.range(l[0],l[1]+d/2,d).map(function(t){var e={};return e[o[0]]=t,e[o[1]]=s(t),u(e)});this.value&&(n.rem=this.value),this.value=n.add=n.source=h}return n};var Le=e.inherits(ft,W);Le.transform=function(t,e){var i,n=this.value,r=t.field,a=n[0],s=n[1],u=e.ADD;i=e.changed()||e.modified(r.fields)||t.modified("field"),i&&(u=e.SOURCE,a=+(1/0),s=-(1/0)),e.visit(u,function(t){var e=r(t);e<a&&(a=e),e>s&&(s=e)}),this.value=[a,s]};var ze=e.inherits(ct,m);ze.connect=function(t){return this.targets().add(t),t.source=this},ze.add=function(t){this.value.add.push(t)},ze.rem=function(t){this.value.rem.push(t)},ze.mod=function(t){this.value.mod.push(t)},ze.init=function(t){this.value.init(t,t.NO_SOURCE)},ze.evaluate=function(){return this.value};var Ie=e.inherits(mt,W);Ie.activate=function(t){this._targets[this._targets.active++]=t},Ie.subflow=function(t,e,i,n){var r,a,s=this.value,u=s.hasOwnProperty(t)&&s[t];return u?u.value.stamp<i.stamp&&(u.init(i),this.activate(u)):(a=n||(a=this._group[t])&&a.tuple,r=i.dataflow,u=r.add(new ct(i.fork(i.NO_SOURCE),this)).connect(e(r,t,a)),s[t]=u,this.activate(u)),u},Ie.transform=function(t,e){function i(t){return r.subflow(t,s,e)}var n=e.dataflow,r=this,a=t.key,s=t.subflow,u=this._keys,o=t.modified("key");return this._group=t.group||{},this._targets.active=0,e.visit(e.REM,function(t){var e=u.get(t._id);void 0!==e&&(u.delete(t._id),i(e).rem(t))}),e.visit(e.ADD,function(t){var e=a(t);u.set(t._id,e),i(e).add(t)}),o||e.modified(a.fields)?e.visit(e.MOD,function(t){var e=u.get(t._id),n=a(t);e===n?i(n).mod(t):(u.set(t._id,n),i(e).rem(t),i(n).add(t))}):e.changed(e.MOD)&&e.visit(e.MOD,function(t){i(u.get(t._id)).mod(t)}),o&&e.visit(e.REFLOW,function(t){var e=u.get(t._id),n=a(t);e!==n&&(u.set(t._id,n),i(e).rem(t),i(n).add(t))}),u.empty>n.cleanThreshold&&n.runAfter(u.clean),e},e.inherits(pt,m);var Te=e.inherits(gt,W);Te.transform=function(t,e){function i(e){var i=l(e,t),n=r.get(e._id);i&&n?(r.delete(e._id),s.push(e)):i||n?d&&i&&!n&&o.push(e):(r.set(e._id,1),u.push(e))}var n=e.dataflow,r=this.value,a=e.fork(),s=a.add,u=a.rem,o=a.mod,l=t.expr,d=!0;return e.visit(e.REM,function(t){r.has(t._id)?r.delete(t._id):u.push(t)}),e.visit(e.ADD,function(e){l(e,t)?s.push(e):r.set(e._id,1)}),e.visit(e.MOD,i),t.modified()&&(d=!1,e.visit(e.REFLOW,i)),r.empty>n.cleanThreshold&&n.runAfter(r.clean),a};var je=e.inherits(_t,W); | ||
je.transform=function(t,e){function i(t){for(var e,i=a[t._id]=Array(m),n=0;n<m;++n)e=i[n]=o(t),e[h]=c[n],e[f]=u[n](t),v.add.push(e)}function n(t){for(var e,i=a[t._id],n=0;n<m;++n)_&1<<n&&(e=l(t,i[n],p),e[h]=c[n],e[f]=u[n](t),v.mod.push(e))}var r,a=this.value,s=t.modified("fields"),u=t.fields,d=t.as||["key","value"],h=d[0],f=d[1],c=u.map(yt),m=u.length,p=e.stamp,v=e.fork(e.NO_SOURCE),g=0,_=0;if(s){for(r in a)v.rem.push.apply(v.rem,a[r]);a=this.value={},e.visit(e.SOURCE,i)}else{for(e.visit(e.ADD,i);g<m;++g)e.modified(u[g].fields)&&(_|=1<<g);_&&e.visit(e.MOD,n),e.visit(e.REM,function(t){v.rem.push.apply(v.rem,a[t._id]),a[t._id]=null})}return v.modifies(d)};var We=e.inherits(xt,W);We.transform=function(t,e){function i(e){e[r]=n(e,t)}var n=t.expr,r=t.as,a=t.modified(),s=t.initonly?e.ADD:a?e.SOURCE:e.modified(n.fields)?e.ADD_MOD:e.ADD;return a&&(e=e.materialize().reflow(!0)),t.initonly||e.modifies(r),e.visit(s,i)};var Ge=e.inherits(kt,W);Ge.transform=function(t,e){var i,n,r,a=this.value,s=e.fork(e.ALL),o=t.size-a.length,l=t.generator;if(o>0){for(i=[];--o>=0;)i.push(r=u(l(t))),a.push(r);s.add=s.add.length?s.materialize(s.ADD).add.concat(i):i}else n=a.slice(0,-o),s.rem=s.rem.length?s.materialize(s.REM).rem.concat(n):n,a=a.slice(-o);return s.source=this.value=a,s};var Ke={value:"value",median:r.median,mean:r.mean,min:r.min,max:r.max},Ve=[],Be=e.inherits(wt,W);Be.transform=function(t,i){var n,r,a,s,o,l,d,h,f,c,m=i.fork(i.ALL),p=Dt(t),v=Ot(t),g=e.accessorName(t.field),_=t.groupby.map(e.accessorName),y=t.orderby.map(e.accessorName),x=qt(i.source,t.groupby,t.orderby),k=[],w=this.value,D=x.domain.length;for(o=0,h=x.length;o<h;++o)for(n=x[o],a=n.values,r=NaN,d=0;d<D;++d)if(null==n[d]){for(s=x.domain[d],c={_impute:!0},l=0,f=a.length;l<f;++l)c[_[l]]=a[l];for(l=0,f=s.length;l<f;++l)c[y[l]]=s[l];c[g]=isNaN(r)?r=p(n,v):r,k.push(u(c))}return k.length&&(m.add=m.materialize(m.ADD).add.concat(k)),w.length&&(m.rem=m.materialize(m.REM).rem.concat(w)),this.value=k,m};var Je=e.inherits(bt,Y);Je.transform=function(t,e){var i,n=this,r=t.modified();return n.value&&(r||e.modified(n._inputs))?(i=n.value=r?n.init(t):{},e.visit(e.SOURCE,function(t){n.add(t)})):(i=n.value=n.value||this.init(t),e.visit(e.REM,function(t){n.rem(t)}),e.visit(e.ADD,function(t){n.add(t)})),n.changes(),e.visit(e.SOURCE,function(t){l(i[n.cellkey(t)].tuple,t)}),e.reflow(r).modifies(this._outputs)},Je.changes=function(){var t,e,i=this._adds,n=this._mods;for(t=0,e=this._alen;t<e;++t)this.celltuple(i[t]),i[t]=null;for(t=0,e=this._mlen;t<e;++t)this.celltuple(n[t]),n[t]=null;this._alen=this._mlen=0},e.inherits(Et,m);var $e=e.inherits(At,W);$e.transform=function(t,i){var n,r,a,s=i,u=t.as,o=t.fields,l=t.index,d=t.values,h=null==t.default?null:t.default,f=t.modified(),c=f?i.SOURCE:i.ADD,m=o.length;return d?(r=d.length,m>1&&!u&&e.error('Multi-field lookup requires explicit "as" parameter.'),u&&u.length!==m*r&&e.error('The "as" parameter has too few output field names.'),u=u||d.map(e.accessorName),n=function(t){for(var e,i,n=0,a=0;n<m;++n)if(i=l.get(o[n](t)),null==i)for(e=0;e<r;++e,++a)t[u[a]]=h;else for(e=0;e<r;++e,++a)t[u[a]]=d[e](i)}):(u||e.error("Missing output field names."),n=function(t){for(var e,i=0;i<m;++i)e=l.get(o[i](t)),t[u[i]]=null==e?h:e}),f?s=i.reflow(!0):(a=o.some(function(t){return i.modified(t.fields)}),c|=a?i.MOD:0),i.visit(c,n),s.modifies(u)},e.inherits(Rt,m),e.inherits(St,m),e.inherits(Ct,W),Ct.prototype.transform=function(t,e){return this.modified(t.modified()),this.value=t,e.fork(e.NO_SOURCE|e.NO_FIELDS)};var He=e.inherits(Pt,mt);He.transform=function(t,i){var n=this,r=t.subflow,a=t.field;return(t.modified("field")||a&&i.modified(e.accessorFields(a)))&&e.error("PreFacet does not support field modification."),this._targets.active=0,i.visit(i.MOD,function(t){var e=n.subflow(t._id,r,i,t);a?a(t).forEach(function(t){e.mod(t)}):e.mod(t)}),i.visit(i.ADD,function(t){var e=n.subflow(t._id,r,i,t);a?a(t).forEach(function(t){e.add(u(t))}):e.add(t)}),i.visit(i.REM,function(t){var e=n.subflow(t._id,r,i,t);a?a(t).forEach(function(t){e.rem(t)}):e.rem(t)}),i};var Qe=e.inherits(Ut,W);Qe.transform=function(t,e){return this.value=t.value,t.modified("value")?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation};var Xe=e.inherits(Lt,W);Xe.transform=function(t,i){i.source||e.error("Rank transform requires an upstream data source.");var n,r=t.normalize,a=t.field,s=t.as||"rank",u={},o=-1;return a?(i.visit(i.SOURCE,function(t){var e=a(t);null==u[e]&&(u[e]=++o)}),i.visit(i.SOURCE,r&&--o?function(t){t[s]=u[a(t)]/o}:function(t){t[s]=u[a(t)]})):(o+=i.source.length,n=-1,i.visit(i.SOURCE,r&&o?function(t){t[s]=++n/o}:function(t){t[s]=++n})),i.reflow(t.modified()).modifies(s)};var Ye=e.inherits(zt,W);Ye.transform=function(t,e){var i,n=this.value||(i=e=e.addAll(),this.value={});return t.derive&&(i=e.fork(),e.visit(e.ADD,function(t){var e=o(t);n[t._id]=e,i.add.push(e)}),e.visit(e.MOD,function(t){i.mod.push(l(t,n[t._id]))}),e.visit(e.REM,function(t){i.rem.push(n[t._id]),n[t._id]=null})),i};var Ze=e.inherits(It,W);Ze.transform=function(t,e){function i(t){var e,i;s.length<a?s.push(t):(i=~~(u*Math.random()),i<s.length&&i>=o&&(e=s[i],l[e._id]&&n.rem.push(e),s[i]=t)),++u}var n=e.fork(),r=t.modified("size"),a=t.size,s=this.value,u=this.count,o=0,l=s.reduce(function(t,e){return t[e._id]=1,t},{});if(e.rem.length&&(e.visit(e.REM,function(t){l[t._id]&&(l[t._id]=-1,n.rem.push(t)),--u}),s=s.filter(function(t){return l[t._id]!==-1})),(e.rem.length||r)&&s.length<a&&e.source&&(o=u=s.length,e.visit(e.SOURCE,function(t){l[t._id]||i(t)}),o=-1),r&&s.length>a){for(var d=0,h=s.length-a;d<h;++d)l[s[d]._id]=-1,n.rem.push(s[d]);s=s.slice(h)}return e.mod.length&&e.visit(e.MOD,function(t){l[t._id]&&n.mod.push(t)}),e.add.length&&e.visit(e.ADD,i),(e.add.length||o<0)&&(n.add=s.filter(function(t){return!l[t._id]})),this.count=u,this.value=n.source=s,n};var ti=e.inherits(Tt,W);ti.transform=function(t,e){if(!this.value||t.modified()){var i=e.materialize().fork(e.MOD);return i.rem=this.value?e.rem.concat(this.value):e.rem,i.source=this.value=r.range(t.start,t.stop,t.step||1).map(u),i.add=e.add.concat(this.value),i}};var ei=e.inherits(jt,W);ei.transform=function(t,e){return this.value=e.source,e.changed()?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation};var ii=e.inherits(Wt,W);ii.transform=function(t,e){function i(t){a.set(r(t),t)}var n=e.dataflow,r=t.field,a=this.value,s=!0;return t.modified("field")||e.modified(r.fields)?(a.clear(),e.visit(e.SOURCE,i)):e.changed()?(e.visit(e.REM,function(t){a.delete(r(t))}),e.visit(e.ADD,i)):s=!1,this.modified(s),a.empty>n.cleanThreshold&&n.runAfter(a.clean),e.fork()};var ni=e.inherits(Gt,W);ni.transform=function(t,e){var i=!this.value||t.modified("field")||t.modified("sort")||e.changed()||t.sort&&e.modified(t.sort.fields);i&&(this.value=(t.sort?e.source.slice().sort(t.sort):e.source).map(t.field))};var ri={type:"Aggregate",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"fields",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:["count","valid","missing","distinct","sum","mean","average","variance","variancep","stdev","stdevp","stderr","median","q1","q3","ci0","ci1","min","max","argmin","argmax"]},{name:"as",type:"string",array:!0},{name:"drop",type:"boolean",default:!0},{name:"cross",type:"boolean",default:!1},{name:"key",type:"field"}]},ai={type:"Bin",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"anchor",type:"number"},{name:"maxbins",type:"number",default:20},{name:"base",type:"number",default:10},{name:"divide",type:"number",array:!0,default:[5,2]},{name:"extent",type:"number",array:!0,length:2,required:!0},{name:"step",type:"number"},{name:"steps",type:"number",array:!0},{name:"minstep",type:"number",default:0},{name:"nice",type:"boolean",default:!0},{name:"name",type:"string"},{name:"as",type:"string",array:!0,length:2,default:["bin0","bin1"]}]},si={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]},ui={type:"CountPattern",metadata:{generates:!0,changes:!0},params:[{name:"field",type:"field",required:!0},{name:"case",type:"enum",values:["upper","lower","mixed"],default:"mixed"},{name:"pattern",type:"string",default:'[\\w"]+'},{name:"stopwords",type:"string",default:""},{name:"as",type:"string",array:!0,length:2,default:["text","count"]}]},oi={type:"Cross",metadata:{source:!0,generates:!0,changes:!0},params:[{name:"filter",type:"expr"},{name:"as",type:"string",array:!0,length:2,default:["a","b"]}]},li=[{key:{function:"normal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"uniform"},params:[{name:"min",type:"number",default:0},{name:"max",type:"number",default:1}]},{key:{function:"kde"},params:[{name:"field",type:"field",required:!0},{name:"from",type:"data"},{name:"bandwidth",type:"number",default:0}]}],di={key:{function:"mixture"},params:[{name:"distributions",type:"param",array:!0,params:li},{name:"weights",type:"number",array:!0}]},hi={type:"Density",metadata:{generates:!0,source:!0},params:[{name:"extent",type:"number",array:!0,length:2},{name:"steps",type:"number",default:100},{name:"method",type:"string",default:"pdf",values:["pdf","cdf"]},{name:"distribution",type:"param",params:li.concat(di)},{name:"as",type:"string",array:!0,default:["value","density"]}]},fi={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]},ci={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]},mi={type:"Fold",metadata:{generates:!0,changes:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0,length:2,default:["key","value"]}]},pi={type:"Formula",metadata:{modifies:!0},params:[{name:"expr",type:"expr",required:!0},{name:"as",type:"string",required:!0},{name:"initonly",type:"boolean"}]},vi={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"orderby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]},gi={type:"JoinAggregate",metadata:{modifies:!0},params:[{name:"groupby",type:"field",array:!0},{name:"fields",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:["count","valid","missing","distinct","sum","mean","average","variance","variancep","stdev","stdevp","stderr","median","q1","q3","ci0","ci1","min","max","argmin","argmax"]},{name:"as",type:"string",array:!0},{name:"key",type:"field"}]},_i={type:"Lookup",metadata:{modifies:!0},params:[{name:"index",type:"index",params:[{name:"from",type:"data",required:!0},{name:"key",type:"field",required:!0}]},{name:"values",type:"field",array:!0},{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0},{name:"default",default:null}]},yi={type:"Rank",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"normalize",type:"boolean",default:!1},{name:"as",type:"string",default:"rank"}]},xi={type:"Sample",metadata:{source:!0,changes:!0},params:[{name:"size",type:"number",default:1e3}]},ki={type:"Sequence",metadata:{generates:!0,source:!0},params:[{name:"start",type:"number",required:!0},{name:"stop",type:"number",required:!0},{name:"step",type:"number",default:1}],output:["value"]};G(ri,Y),G(ai,et),G(si,it),G(ui,at),G(oi,ut),G(hi,dt),G(fi,ft),G(ci,gt),G(mi,_t),G(pi,xt),G(vi,wt),G(gi,bt),G(_i,At),G(yi,Lt),G(xi,It),G(ki,Tt),V("Compare",nt),V("Facet",mt),V("Field",pt),V("Generate",kt),V("Key",Et),V("MultiExtent",Rt),V("MultiValues",St),V("Params",Ct),V("PreFacet",Pt),V("Proxy",Ut),V("Relay",zt),V("Sieve",jt),V("Subflow",ct),V("TupleIndex",Wt),V("Values",Gt),t.UniqueList=a,t.changeset=f,t.isChangeSet=h,t.Dataflow=T,t.EventStream=v,t.Parameters=c,t.Pulse=w,t.MultiPulse=M,t.Operator=m,t.Transform=W,t.ingest=u,t.tupleid=s,t.definition=K,t.definitions=Oe,t.register=G,t.transform=V,t.transforms=De,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-util"),require("vega-loader"),require("vega-statistics"),require("d3-array")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-loader","vega-statistics","d3-array"],e):e(t.vega=t.vega||{},t.vega,t.vega,t.vega,t.d3)}(this,function(t,e,i,n,r){"use strict";function a(t){var i=t||e.identity,n=[],r={};return n.add=function(t){var e=i(t);return r[e]||(r[e]=1,n.push(t)),n},n.remove=function(t){var e,a=i(t);return r[a]&&(r[a]=0,(e=n.indexOf(t))>=0&&n.splice(e,1)),n},n}function s(t){var e=t===Object(t)?t:{data:t};return e._id||(e._id=++Mt),e}function u(t){return s(o(t,{}))}function o(t,e){for(var i in t)"_id"!==i&&(e[i]=t[i]);return e}function l(t,e){return e._id=t._id,e}function d(t){return t&&t.constructor===h}function h(){var t=[],i=[],n=[],r=[],a=[],u=!1;return{constructor:h,insert:function(i){for(var n=e.array(i),r=0,a=n.length;r<a;++r)t.push(n[r]);return this},remove:function(t){for(var n=e.isFunction(t)?r:i,a=e.array(t),s=0,u=a.length;s<u;++s)n.push(a[s]);return this},modify:function(t,i,r){var s={field:i,value:e.constant(r)};return e.isFunction(t)?(s.filter=t,a.push(s)):(s.tuple=t,n.push(s)),this},encode:function(t,i){return e.isFunction(t)?a.push({filter:t,field:i}):n.push({tuple:t,field:i}),this},reflow:function(){return u=!0,this},pulse:function(e,o){function l(t,i,n){n?t[i]=n(t):e.encode=i,u||(d[t._id]=t)}var d,h,f,c,m,p,v;for(h=0,f=t.length;h<f;++h)e.add.push(s(t[h]));for(d={},h=0,f=i.length;h<f;++h)d[(p=i[h])._id]=p;for(h=0,f=r.length;h<f;++h)m=r[h],o.forEach(function(t){m(t)&&(d[t._id]=t)});for(v in d)e.rem.push(d[v]);for(d={},h=0,f=n.length;h<f;++h)l((c=n[h]).tuple,c.field,c.value),e.modifies(c.field);for(h=0,f=a.length;h<f;++h)c=a[h],m=c.filter,o.forEach(function(t){m(t)&&l(t,c.field,c.value)}),e.modifies(c.field);if(u)e.mod=i.length||r.length?o.filter(function(t){return d.hasOwnProperty(t._id)}):o.slice();else for(v in d)e.mod.push(d[v]);return e}}}function f(){Object.defineProperty(this,St,{writable:!0,value:{}})}function c(t,e,i,n){this.id=++Ct,this.value=t,this.stamp=-1,this.rank=-1,this.qrank=-1,this.flags=0,e&&(this._update=e),i&&this.parameters(i,n)}function m(t){return function(e){var i=this.flags;return 0===arguments.length?!!(i&t):(this.flags=e?i|t:i&~t,this)}}function p(t,e,i){this.id=++Lt,this.value=null,i&&(this.receive=i),t&&(this._filter=t),e&&(this._apply=e)}function v(t,e,i){return new p(t,e,i)}function g(t,i,n,r,a,s){var u,o,l=e.extend({},s,It);e.isFunction(n)||(n=e.constant(n)),void 0===r?u=function(e){t.touch(n(e))}:e.isFunction(r)?(o=new c(null,r,a,!1),u=function(e){var i,r=n(e);o.evaluate(e),d(i=o.value)?t.pulse(r,i,s):t.update(r,i,l)}):u=function(e){t.update(n(e),r,l)},i.apply(u)}function _(t,i,n,r,a,s){var u,o;void 0===r?o=n:(u=e.isFunction(r)?r:e.constant(r),(o=new c(null,r=n?function(t,e){var i=u(t,e);return n.skip()?i:n.skip(!0).value=i}:u,a,!1)).modified(s&&s.force),o.rank=0,n&&(o.skip(!0),o.value=n.value,o.targets().add(n))),i.targets().add(o)}function y(t,e,i){this.dataflow=t,this.stamp=null==e?-1:e,this.add=[],this.rem=[],this.mod=[],this.fields=null,this.encode=i||null}function x(t,e){return t?function(i,n){return t(i,n)&&e(i,n)}:e}function k(t,e){var i={};return t.visit(e,function(t){i[t._id]=1}),function(t){return i[t._id]?null:t}}function w(t){var e,i,n=new Promise(function(t,n){e=t,i=n});return n.requests=0,n.done=function(){0==--n.requests&&t.runAfter(function(){t._pending=null;try{t.run(),e(t)}catch(t){i(t)}})},t._pending=n}function D(t,e,i,n){var r,a,s,u,o,l=this,d=0;for(this.dataflow=t,this.stamp=e,this.fields=null,this.encode=n||null,this.pulses=i,s=0,u=i.length;s<u;++s)if((r=i[s]).stamp===e){if(r.fields){a=l.fields||(l.fields={});for(o in r.fields)a[o]=1}r.changed(l.ADD)&&(d|=l.ADD),r.changed(l.REM)&&(d|=l.REM),r.changed(l.MOD)&&(d|=l.MOD)}this.changes=d}function O(t){this.cmp=t,this.nodes=[]}function q(t,e,i,n){var r,a,s;for(r=t[i];i>e&&n(r,a=t[s=i-1>>1])<0;)t[i]=a,i=s;return t[i]=r}function E(t,e,i){for(var n,r=e,a=t.length,s=t[e],u=2*e+1;u<a;)(n=u+1)<a&&i(t[u],t[n])>=0&&(u=n),t[e]=t[u],u=2*(e=u)+1;return t[e]=s,q(t,r,e,i)}function b(){this._log=e.logger(),this._clock=0,this._rank=0,this._loader=i.loader(),this._touched=a(e.id),this._pulses={},this._pulse=null,this._heap=new O(function(t,e){return t.qrank-e.qrank}),this._postrun=[]}function F(t){return function(){return this._log[t].apply(this,arguments)}}function A(t,e){c.call(this,t,null,e)}function R(t,e){var i=t.type;M(i,t),S(i,e)}function M(t,e){return t=t&&t.toLowerCase(),arguments.length>1?($t[t]=e,this):$t.hasOwnProperty(t)?$t[t]:null}function S(t,e){return arguments.length>1?(Jt[t]=e,this):Jt.hasOwnProperty(t)?Jt[t]:null}function N(t){this._key=t||"_id",this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null}function C(t,e){return Qt[t](e)}function P(t){return function(i){var n=e.extend({init:"",add:"",rem:"",idx:0},t);return n.out=i||t.name,n}}function U(t,e){return t.idx-e.idx}function L(t,e){function i(t,n){function r(e){t[e]||i(t,t[e]=Qt[e]())}return n.req&&n.req.forEach(r),e&&n.str&&n.str.forEach(r),t}var n,r=t.reduce(i,t.reduce(function(t,e){return t[e.name]=e,t},{})),a=[];for(n in r)a.push(r[n]);return a.sort(U)}function z(t,i){var n=i||e.identity,r="this.cell = cell; this.tuple = t; this.valid = 0; this.missing = 0;",a="if(v==null){++this.missing; return;} if(v!==v) return; ++this.valid;",s="if(v==null){--this.missing; return;} if(v!==v) return; --this.valid;",u="var t = this.tuple; var cell = this.cell;";return L(t,!0).forEach(function(t){t.idx<0?(r=t.init+r,a=t.add+a,s=t.rem+s):(r+=t.init,a+=t.add,s+=t.rem)}),t.slice().sort(U).forEach(function(t){u+="t['"+t.out+"']="+t.set+";"}),u+="return t;",r=Function("cell","t",r),r.prototype.add=Function("v","t",a),r.prototype.rem=Function("v","t",s),r.prototype.set=Function(u),r.prototype.get=n,r.fields=t.map(function(t){return t.out}),r}function I(t){A.call(this,null,t),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._cross=!1,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}function T(t,e,i){return i||t+(e?"_"+e:"")}function j(t){var e,i=this._dims,n=i.length,r=String(i[0](t));for(e=1;e<n;++e)r+="|"+i[e](t);return r}function W(t){A.call(this,null,t)}function G(t){A.call(this,[],t)}function K(t){c.call(this,null,V,t)}function V(t){return this.value&&!t.modified()?this.value:e.compare(t.fields,t.orders)}function B(t){A.call(this,null,t)}function J(t,e,i){switch(e){case"upper":t=t.toUpperCase();break;case"lower":t=t.toLowerCase()}return t.match(i)}function $(t){A.call(this,null,t)}function H(t,e,i,n){for(var r,a,u=[],o={},l=t.length,d=0;d<l;++d)for(o[e]=a=t[d],r=0;r<l;++r)o[i]=t[r],n(o)&&(u.push(s(o)),(o={})[e]=a);return u}function Q(t,i){var n=t[ie];te.hasOwnProperty(n)||e.error("Unknown distribution function: "+n);var r=te[n]();for(var a in t)a===ne?r.data((t.from||i()).map(t[a])):a===ee?r[a](t[a].map(function(t){return Q(t,i)})):typeof r[a]===ie&&r[a](t[a]);return r}function X(t){A.call(this,null,t)}function Y(t){return function(){return t.materialize(t.SOURCE).source}}function Z(t){A.call(this,[1/0,-1/0],t)}function tt(t,e){c.call(this,t),this.parent=e}function et(t){A.call(this,{},t),this._keys=e.fastmap();var i=this._targets=[];i.active=0,i.forEach=function(t){for(var e=0,n=i.active;e<n;++e)t(i[e],e,i)}}function it(t){c.call(this,null,nt,t)}function nt(t){return this.value&&!t.modified()?this.value:e.isArray(t.name)?e.array(t.name).map(function(t){return e.field(t)}):e.field(t.name,t.as)}function rt(t){A.call(this,e.fastmap(),t)}function at(t){A.call(this,{},t)}function st(t){return t.fields.join("|")}function ut(t){A.call(this,null,t)}function ot(t){A.call(this,[],t)}function lt(t){A.call(this,[],t)}function dt(t){var i,n=t.method||se.value;if(null!=se[n])return n===se.value?(i=void 0!==t.value?t.value:0,function(){return i}):se[n];e.error("Unrecognized imputation method: "+n)}function ht(t){var e=t.field;return function(t){return t?e(t):NaN}}function ft(t,e,i,n){var r,a,s,u,o,l,d,h,f=[],c=n?n.slice():[],m={},p={};for(c.forEach(function(t,e){m[t]=e+1}),u=0,d=t.length;u<d;++u)l=i(h=t[u]),o=m[l]||(m[l]=c.push(l)),(s=p[a=(r=e?e.map(function(t){return t(h)}):ue)+""])||(s=p[a]=[],f.push(s),s.values=r),s[o-1]=h;return f.domain=c,f}function ct(t){I.call(this,t)}function mt(t){c.call(this,null,pt,t)}function pt(t){return this.value&&!t.modified()?this.value:e.key(t.fields)}function vt(t){A.call(this,{},t)}function gt(t){c.call(this,null,_t,t)}function _t(t){if(this.value&&!t.modified())return this.value;var e,i,n,r=1/0,a=-1/0,s=t.extents;for(e=0,i=s.length;e<i;++e)(n=s[e])[0]<r&&(r=n[0]),n[1]>a&&(a=n[1]);return[r,a]}function yt(t){c.call(this,null,xt,t)}function xt(t){return this.value&&!t.modified()?this.value:t.values.reduce(function(t,e){return t.concat(e)},[])}function kt(t){A.call(this,null,t)}function wt(t){et.call(this,t)}function Dt(t){A.call(this,null,t)}function Ot(t){A.call(this,null,t)}function qt(t){A.call(this,null,t)}function Et(t){A.call(this,[],t),this.count=0}function bt(t){A.call(this,null,t)}function Ft(t){A.call(this,null,t),this.modified(!0)}function At(t){A.call(this,e.fastmap(),t)}function Rt(t){A.call(this,null,t)}var Mt=1,St="_:mod:_",Nt=f.prototype;Nt.set=function(t,i,n,r){var a=this,s=a[t],u=a[St];return null!=i&&i>=0?(s[i]!==n||r)&&(s[i]=n,u[i+":"+t]=-1,u[t]=-1):(s!==n||r)&&(a[t]=n,u[t]=e.isArray(n)?1+n.length:-1),a},Nt.modified=function(t,i){var n,r=this[St];if(!arguments.length){for(n in r)if(r[n])return!0;return!1}if(e.isArray(t)){for(n=0;n<t.length;++n)if(r[t[n]])return!0;return!1}return null!=i&&i>=0?i+1<r[t]||!!r[i+":"+t]:!!r[t]},Nt.clear=function(){return this[St]={},this};var Ct=0,Pt=new f,Ut=c.prototype;Ut.targets=function(){return this._targets||(this._targets=a(e.id))},Ut.set=function(t){return this.value!==t?(this.value=t,1):0},Ut.skip=m(1),Ut.modified=m(2),Ut.parameters=function(t,i){function n(t,e,n){n instanceof c?(n!==o&&(i&&n.targets().add(o),h.push(n)),d.push({op:n,name:t,index:e})):l.set(t,e,n)}i=!1!==i;var r,a,s,u,o=this,l=o._argval=o._argval||new f,d=o._argops=o._argops||[],h=[];for(r in t)if(a=t[r],"pulse"===r)e.array(a).forEach(function(t){t instanceof c?t!==o&&(t.targets().add(o),h.push(t)):e.error("Pulse parameters must be operator instances.")}),o.source=a;else if(e.isArray(a))for(l.set(r,-1,Array(s=a.length)),u=0;u<s;++u)n(r,u,a[u]);else n(r,-1,a);return this.marshall().clear(),h},Ut.marshall=function(t){var e,i,n,r,a,s=this._argval||Pt,u=this._argops;if(u&&(n=u.length))for(i=0;i<n;++i)a=(r=(e=u[i]).op).modified()&&r.stamp===t,s.set(e.name,e.index,r.value,a);return s},Ut.evaluate=function(t){if(this._update){var e=this.marshall(t.stamp),i=this._update(e,t);if(e.clear(),i!==this.value)this.value=i;else if(!this.modified())return t.StopPropagation}},Ut.run=function(t){if(t.stamp<=this.stamp)return t.StopPropagation;var e;return this.skip()?(this.skip(!1),e=0):e=this.evaluate(t),this.stamp=t.stamp,this.pulse=e,e||t};var Lt=0,zt=p.prototype;zt._filter=e.truthy,zt._apply=e.identity,zt.targets=function(){return this._targets||(this._targets=a(e.id))},zt.consume=function(t){return arguments.length?(this._consume=!!t,this):!!this._consume},zt.receive=function(t){if(this._filter(t)){for(var e=this.value=this._apply(t),i=this._targets,n=i?i.length:0,r=0;r<n;++r)i[r].receive(e);this._consume&&(t.preventDefault(),t.stopPropagation())}},zt.filter=function(t){var e=v(t);return this.targets().add(e),e},zt.apply=function(t){var e=v(null,t);return this.targets().add(e),e},zt.merge=function(){var t=v();this.targets().add(t);for(var e=0,i=arguments.length;e<i;++e)arguments[e].targets().add(t);return t},zt.throttle=function(t){var e=-1;return this.filter(function(){var i=Date.now();return i-e>t?(e=i,1):0})},zt.debounce=function(t){var i=v();return this.targets().add(v(null,null,e.debounce(t,function(t){var e=t.dataflow;i.receive(t),e&&e.run&&e.run()}))),i},zt.between=function(t,e){var i=!1;return t.targets().add(v(null,null,function(){i=!0})),e.targets().add(v(null,null,function(){i=!1})),this.filter(function(){return i})};var It={skip:!0},Tt={},jt=y.prototype;jt.StopPropagation=Tt,jt.ADD=1,jt.REM=2,jt.MOD=4,jt.ADD_REM=3,jt.ADD_MOD=5,jt.ALL=7,jt.REFLOW=8,jt.SOURCE=16,jt.NO_SOURCE=32,jt.NO_FIELDS=64,jt.fork=function(t){return new y(this.dataflow).init(this,t)},jt.addAll=function(){var t=this;return this.source&&this.source.length!==this.add.length?(t=new y(this.dataflow).init(this),t.add=t.source,t):t},jt.init=function(t,e){var i=this;return i.stamp=t.stamp,i.encode=t.encode,!t.fields||64&e||(i.fields=t.fields),1&e?(i.addF=t.addF,i.add=t.add):(i.addF=null,i.add=[]),2&e?(i.remF=t.remF,i.rem=t.rem):(i.remF=null,i.rem=[]),4&e?(i.modF=t.modF,i.mod=t.mod):(i.modF=null,i.mod=[]),32&e?(i.srcF=null,i.source=null):(i.srcF=t.srcF,i.source=t.source),i},jt.runAfter=function(t){this.dataflow.runAfter(t)},jt.changed=function(t){var e=t||7;return 1&e&&this.add.length||2&e&&this.rem.length||4&e&&this.mod.length},jt.reflow=function(t){if(t)return this.fork(7).reflow();var e=this.add.length,i=this.source&&this.source.length;return i&&i!==e&&(this.mod=this.source,e&&this.filter(4,k(this,1))),this},jt.modifies=function(t){var i=e.array(t),n=this.fields||(this.fields={});return i.forEach(function(t){n[t]=!0}),this},jt.modified=function(t){var i=this.fields;return!(!this.mod.length||!i)&&(arguments.length?e.isArray(t)?t.some(function(t){return i[t]}):i[t]:!!i)},jt.filter=function(t,e){var i=this;return 1&t&&(i.addF=x(i.addF,e)),2&t&&(i.remF=x(i.remF,e)),4&t&&(i.modF=x(i.modF,e)),16&t&&(i.srcF=x(i.srcF,e)),i},jt.materialize=function(t){var e=this;return 1&(t=t||7)&&e.addF&&(e.add=e.add.filter(e.addF),e.addF=null),2&t&&e.remF&&(e.rem=e.rem.filter(e.remF),e.remF=null),4&t&&e.modF&&(e.mod=e.mod.filter(e.modF),e.modF=null),16&t&&e.srcF&&(e.source=e.source.filter(e.srcF),e.srcF=null),e},jt.visit=function(t,i){var n,r,a=i;return 16&t?(e.visitArray(this.source,this.srcF,a),this):(1&t&&e.visitArray(this.add,this.addF,a),2&t&&e.visitArray(this.rem,this.remF,a),4&t&&e.visitArray(this.mod,this.modF,a),8&t&&(n=this.source)&&((r=this.add.length+this.mod.length)===n.length||(r?e.visitArray(n,k(this,5),a):e.visitArray(n,this.srcF,a))),this)};var Wt={skip:!1,force:!1},Gt=e.inherits(D,y);Gt.fork=function(){return arguments.length&&arguments[0]&y.prototype.ALL&&e.error("MultiPulse fork does not support tuple change sets."),new y(this.dataflow).init(this,0)},Gt.changed=function(t){return this.changes&t},Gt.modified=function(t){var i=this,n=i.fields;return n&&i.changes&i.MOD?e.isArray(t)?t.some(function(t){return n[t]}):n[t]:0},Gt.filter=function(){e.error("MultiPulse does not support filtering.")},Gt.materialize=function(){e.error("MultiPulse does not support materialization.")},Gt.visit=function(t,e){var i=this,n=i.pulses,r=n.length,a=0;if(t&i.SOURCE)for(;a<r;++a)n[a].visit(t,e);else for(;a<r;++a)n[a].stamp===i.stamp&&n[a].visit(t,e);return i};var Kt=O.prototype;Kt.size=function(){return this.nodes.length},Kt.clear=function(){return this.nodes=[],this},Kt.peek=function(){return this.nodes[0]},Kt.push=function(t){var e=this.nodes;return e.push(t),q(e,0,e.length-1,this.cmp)},Kt.pop=function(){var t,e=this.nodes,i=e.pop();return e.length?(t=e[0],e[0]=i,E(e,0,this.cmp)):t=i,t},Kt.replace=function(t){var e=this.nodes,i=e[0];return e[0]=t,E(e,0,this.cmp),i},Kt.pushpop=function(t){var e=this.nodes,i=e[0];return e.length&&this.cmp(i,t)<0&&(e[0]=t,t=i,E(e,0,this.cmp)),t};var Vt=b.prototype;Vt.stamp=function(){return this._clock},Vt.loader=function(t){return arguments.length?(this._loader=t,this):this._loader},Vt.cleanThreshold=1e4,Vt.add=function(t,i,n,r){var a,s=1;return t instanceof c?a=t:t&&t.prototype instanceof c?a=new t:e.isFunction(t)?a=new c(null,t):(s=0,a=new c(t,i)),this.rank(a),s&&(r=n,n=i),n&&this.connect(a,a.parameters(n,r)),this.touch(a),a},Vt.connect=function(t,e){var i,n,r=t.rank;for(i=0,n=e.length;i<n;++i)if(r<e[i].rank)return void this.rerank(t)},Vt.rank=function(t){t.rank=++this._rank},Vt.rerank=function(t){for(var e,i,n,r=[t];r.length;)if(this.rank(e=r.pop()),i=e._targets)for(n=i.length;--n>=0;)r.push(e=i[n]),e===t&&this.error("Cycle detected in dataflow graph.")},Vt.pulse=function(t,e,i){this.touch(t,i||Wt);var n=new y(this,this._clock+(this._pulse?0:1));return n.target=t,this._pulses[t.id]=e.pulse(n,t.value),this},Vt.touch=function(t,e){var i=e||Wt;return this._pulse?this._enqueue(t):this._touched.add(t),i.skip&&t.skip(!0),this},Vt.update=function(t,e,i){var n=i||Wt;return(t.set(e)||n.force)&&this.touch(t,n),this},Vt.changeset=h,Vt.ingest=function(t,e,n){return this.pulse(t,this.changeset().insert(i.read(e,n)))},Vt.request=function(t,e,i){var n=this,r=n._pending||w(n);r.requests+=1,n.loader().load(e,{context:"dataflow"}).then(function(e){n.ingest(t,e,i)},function(t){n.warn("Loading failed: "+e,t),r.done()}).then(r.done).catch(function(t){n.warn(t)})},Vt.events=function(t,i,n,r){for(var a,s=this,u=v(n,r),o=0,l=(a="string"==typeof t&&"undefined"!=typeof document?document.querySelectorAll(t):e.array(t)).length;o<l;++o)a[o].addEventListener(i,function(t){t.dataflow=s,u.receive(t),s.run()});return u},Vt.on=function(t,e,i,n,r){return(t instanceof c?_:g)(this,t,e,i,n,r),this},Vt.run=function(t){if(!this._touched.length)return 0;if(this._pending)return this.info("Awaiting requests, delaying dataflow run."),0;var i,n,r,s=this,u=0,o=s.logLevel();s._pulse=new y(s,++s._clock,t),o>=e.Info&&(r=Date.now(),s.debug("-- START PROPAGATION ("+s._clock+") -----")),s._touched.forEach(function(t){s._enqueue(t,!0)}),s._touched=a(e.id);try{for(;s._heap.size()>0;)(i=s._heap.pop()).rank===i.qrank?(n=i.run(s._getPulse(i,t)),o>=e.Debug&&s.debug(i.id,n===Tt?"STOP":n,i),n!==Tt&&(s._pulse=n,i._targets&&i._targets.forEach(function(t){s._enqueue(t)})),++u):s._enqueue(i,!0)}catch(t){s.error(t)}if(s._pulses={},s._pulse=null,o>=e.Info&&(r=Date.now()-r,s.info("> Pulse "+s._clock+": "+u+" operators; "+r+"ms")),s._postrun.length){var l=s._postrun;s._postrun=[],l.forEach(function(t){try{t(s)}catch(t){s.error(t)}})}return u},Vt.runAsync=function(){return this._pending||Promise.resolve(this.run())},Vt.runAfter=function(t){if(this._pulse)this._postrun.push(t);else try{t(this)}catch(t){this.error(t)}},Vt._enqueue=function(t,e){var i=!this._pulses[t.id];i&&(this._pulses[t.id]=this._pulse),(i||e)&&(t.qrank=t.rank,this._heap.push(t))},Vt._getPulse=function(t,i){var n,r=t.source,a=this._clock;return r&&e.isArray(r)?(n=r.map(function(t){return t.pulse}),new D(this,a,n,i)):(r=r&&r.pulse,n=this._pulses[t.id],r&&r!==Tt&&(r.stamp===a&&n.target!==t?n=r:n.source=r.source),n)},Vt.warn=F("warn"),Vt.info=F("info"),Vt.debug=F("debug"),Vt.logLevel=F("level"),Vt.error=function(t){throw t};var Bt=e.inherits(A,c);Bt.run=function(t){if(t.stamp<=this.stamp)return t.StopPropagation;var e;return this.skip()?this.skip(!1):e=this.evaluate(t),(e=e||t)!==t.StopPropagation&&(this.pulse=e),this.stamp=t.stamp,e},Bt.evaluate=function(t){var e=this.marshall(t.stamp),i=this.transform(e,t);return e.clear(),i},Bt.transform=function(){};var Jt={},$t={},Ht=N.prototype;Ht.add=function(t){this._add.push(t)},Ht.rem=function(t){this._rem.push(t)},Ht.values=function(){if(this._get=null,0===this._rem.length)return this._add;var t,e,i,n=this._add,r=this._rem,a=this._key,s=n.length,u=r.length,o=Array(s-u),l={};for(t=0;t<u;++t)l[r[t][a]]=1;for(t=0,e=0;t<s;++t)l[(i=n[t])[a]]?l[i[a]]=0:o[e++]=i;return this._rem=[],this._add=o},Ht.distinct=function(t){for(var e,i=this.values(),n=i.length,r={},a=0;--n>=0;)e=t(i[n])+"",r.hasOwnProperty(e)||(r[e]=1,++a);return a},Ht.extent=function(t){if(this._get!==t||!this._ext){var i=this.values(),n=e.extentIndex(i,t);this._ext=[i[n[0]],i[n[1]]],this._get=t}return this._ext},Ht.argmin=function(t){return this.extent(t)[0]||{}},Ht.argmax=function(t){return this.extent(t)[1]||{}},Ht.min=function(t){var e=this.extent(t)[0];return null!=e?t(e):1/0},Ht.max=function(t){var e=this.extent(t)[1];return null!=e?t(e):-1/0},Ht.quartile=function(t){return this._get===t&&this._q||(this._q=n.quartiles(this.values(),t),this._get=t),this._q},Ht.q1=function(t){return this.quartile(t)[0]},Ht.q2=function(t){return this.quartile(t)[1]},Ht.q3=function(t){return this.quartile(t)[2]},Ht.ci=function(t){return this._get===t&&this._ci||(this._ci=n.bootstrapCI(this.values(),1e3,.05,t),this._get=t),this._ci},Ht.ci0=function(t){return this.ci(t)[0]},Ht.ci1=function(t){return this.ci(t)[1]};var Qt={values:P({name:"values",init:"cell.store = true;",set:"cell.data.values()",idx:-1}),count:P({name:"count",set:"cell.num"}),missing:P({name:"missing",set:"this.missing"}),valid:P({name:"valid",set:"this.valid"}),sum:P({name:"sum",init:"this.sum = 0;",add:"this.sum += v;",rem:"this.sum -= v;",set:"this.sum"}),mean:P({name:"mean",init:"this.mean = 0;",add:"var d = v - this.mean; this.mean += d / this.valid;",rem:"var d = v - this.mean; this.mean -= this.valid ? d / this.valid : this.mean;",set:"this.mean"}),average:P({name:"average",set:"this.mean",req:["mean"],idx:1}),variance:P({name:"variance",init:"this.dev = 0;",add:"this.dev += d * (v - this.mean);",rem:"this.dev -= d * (v - this.mean);",set:"this.valid > 1 ? this.dev / (this.valid-1) : 0",req:["mean"],idx:1}),variancep:P({name:"variancep",set:"this.valid > 1 ? this.dev / this.valid : 0",req:["variance"],idx:2}),stdev:P({name:"stdev",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid-1)) : 0",req:["variance"],idx:2}),stdevp:P({name:"stdevp",set:"this.valid > 1 ? Math.sqrt(this.dev / this.valid) : 0",req:["variance"],idx:2}),stderr:P({name:"stderr",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid * (this.valid-1))) : 0",req:["variance"],idx:2}),distinct:P({name:"distinct",set:"cell.data.distinct(this.get)",req:["values"],idx:3}),ci0:P({name:"ci0",set:"cell.data.ci0(this.get)",req:["values"],idx:3}),ci1:P({name:"ci1",set:"cell.data.ci1(this.get)",req:["values"],idx:3}),median:P({name:"median",set:"cell.data.q2(this.get)",req:["values"],idx:3}),q1:P({name:"q1",set:"cell.data.q1(this.get)",req:["values"],idx:3}),q3:P({name:"q3",set:"cell.data.q3(this.get)",req:["values"],idx:3}),argmin:P({name:"argmin",add:"if (v < this.min) this.argmin = t;",rem:"if (v <= this.min) this.argmin = null;",set:"this.argmin || cell.data.argmin(this.get)",req:["min"],str:["values"],idx:3}),argmax:P({name:"argmax",add:"if (v > this.max) this.argmax = t;",rem:"if (v >= this.max) this.argmax = null;",set:"this.argmax || cell.data.argmax(this.get)",req:["max"],str:["values"],idx:3}),min:P({name:"min",init:"this.min = null;",add:"if (v < this.min || this.min === null) this.min = v;",rem:"if (v <= this.min) this.min = NaN;",set:"this.min = (isNaN(this.min) ? cell.data.min(this.get) : this.min)",str:["values"],idx:4}),max:P({name:"max",init:"this.max = null;",add:"if (v > this.max || this.max === null) this.max = v;",rem:"if (v >= this.max) this.max = NaN;",set:"this.max = (isNaN(this.max) ? cell.data.max(this.get) : this.max)",str:["values"],idx:4})},Xt=e.inherits(I,A);Xt.transform=function(t,e){var i,n=this,r=e.fork(e.NO_SOURCE|e.NO_FIELDS);return this.stamp=r.stamp,this.value&&((i=t.modified())||e.modified(this._inputs))?(this._prev=this.value,this.value=i?this.init(t):{},e.visit(e.SOURCE,function(t){n.add(t)})):(this.value=this.value||this.init(t),e.visit(e.REM,function(t){n.rem(t)}),e.visit(e.ADD,function(t){n.add(t)})),r.modifies(this._outputs),n._drop=!1!==t.drop,t.cross&&n._dims.length>1&&(n._drop=!1,this.cross()),n.changes(r)},Xt.cross=function(){function t(t){var e,i,n,u;for(e in t)for(n=t[e].tuple,i=0;i<s;++i)a[i][u=n[r[i]]]=u}function e(t,u,o){var l,d,h=r[o],f=a[o++];for(l in f)u[h]=f[l],d=t?t+"|"+l:l,o<s?e(d,u,o):n[d]||i.cell(d,u)}var i=this,n=i.value,r=i._dnames,a=r.map(function(){return{}}),s=r.length;t(i._prev),t(n),e("",{},0)},Xt.init=function(t){function i(t){for(var e,i=t.fields,r=0,s=i.length;r<s;++r)a[e=i[r]]||(a[e]=1,n.push(e))}var n=this._inputs=[],r=this._outputs=[],a={};this._dims=e.array(t.groupby),this._dnames=this._dims.map(function(t){var n=e.accessorName(t);return i(t),r.push(n),n}),this.cellkey=t.key?t.key:0===this._dims.length?function(){return""}:1===this._dims.length?this._dims[0]:j,this._countOnly=!0,this._counts=[],this._measures=[];var s,u,o,l,d,h,f=t.fields||[null],c=t.ops||["count"],m=t.as||[],p=f.length,v={};for(p!==c.length&&e.error("Unmatched number of fields and aggregate ops."),h=0;h<p;++h)s=f[h],u=c[h],null==s&&"count"!==u&&e.error("Null aggregate field specified."),d=T(u,l=e.accessorName(s),m[h]),r.push(d),"count"!==u?((o=v[l])||(i(s),(o=v[l]=[]).field=s,this._measures.push(o)),"count"!==u&&(this._countOnly=!1),o.push(C(u,d))):this._counts.push(d);return this._measures=this._measures.map(function(t){return z(t,t.field)}),{}},Xt.cellkey=j,Xt.cell=function(t,e){var i=this.value[t];return i?0===i.num&&this._drop&&i.stamp<this.stamp?(i.stamp=this.stamp,this._adds[this._alen++]=i):i.stamp<this.stamp&&(i.stamp=this.stamp,this._mods[this._mlen++]=i):(i=this.value[t]=this.newcell(t,e),this._adds[this._alen++]=i),i},Xt.newcell=function(t,e){var i={key:t,num:0,agg:null,tuple:this.newtuple(e,this._prev&&this._prev[t]),stamp:this.stamp,store:!1};if(!this._countOnly){var n,r=this._measures,a=r.length;for(i.agg=Array(a),n=0;n<a;++n)i.agg[n]=new r[n](i,i.tuple)}return i.store&&(i.data=new N),i},Xt.newtuple=function(t,e){var i,n,r=this._dnames,a=this._dims,u={};for(i=0,n=a.length;i<n;++i)u[r[i]]=a[i](t);return e?l(e.tuple,u):s(u)},Xt.add=function(t){var e,i,n,r=this.cellkey(t),a=this.cell(r,t);if(a.num+=1,!this._countOnly)for(a.store&&a.data.add(t),i=0,n=(e=a.agg).length;i<n;++i)e[i].add(e[i].get(t),t)},Xt.rem=function(t){var e,i,n,r=this.cellkey(t),a=this.cell(r,t);if(a.num-=1,!this._countOnly)for(a.store&&a.data.rem(t),i=0,n=(e=a.agg).length;i<n;++i)e[i].rem(e[i].get(t),t)},Xt.celltuple=function(t){var e,i,n,r=t.tuple,a=this._counts;for(t.store&&t.data.values(),i=0,n=a.length;i<n;++i)r[a[i]]=t.num;if(!this._countOnly)for(i=0,n=(e=t.agg).length;i<n;++i)e[i].set();return r},Xt.changes=function(t){var e,i,n,r,a=this._adds,s=this._mods,u=this._prev,o=this._drop,l=t.add,d=t.rem,h=t.mod;if(u)for(i in u)d.push(u[i].tuple);for(n=0,r=this._alen;n<r;++n)l.push(this.celltuple(a[n])),a[n]=null;for(n=0,r=this._mlen;n<r;++n)(0===(e=s[n]).num&&o?d:h).push(this.celltuple(e)),s[n]=null;return this._alen=this._mlen=0,this._prev=null,t};var Yt=e.inherits(W,A);Yt.transform=function(t,i){var n,r=this._bins(t),a=r.start,s=r.step,u=t.as||["bin0","bin1"],o=u[0],l=u[1];return n=t.modified()?(i=i.reflow(!0)).SOURCE:i.modified(e.accessorFields(t.field))?i.ADD_MOD:i.ADD,i.visit(n,function(t){var e=r(t);t[o]=e,t[l]=null==e?null:a+s*(1+(e-a)/s)}),i.modifies(u)},Yt._bins=function(t){if(this.value&&!t.modified())return this.value;var i,r,a=t.field,s=n.bin(t),u=s.start,o=s.stop,l=s.step;null!=(i=t.anchor)&&(r=i-(u+l*Math.floor((i-u)/l)),u+=r,o+=r);var d=function(t){var e=a(t);return null==e?null:(e=Math.max(u,Math.min(+e,o-l)),u+l*Math.floor((e-u)/l))};return d.start=u,d.stop=o,d.step=l,this.value=e.accessor(d,e.accessorFields(a),t.name||"bin_"+e.accessorName(a))},e.inherits(G,A).transform=function(t,i){var n,r=i.fork(i.ALL),a=i.changed(i.ADD),s=i.changed(),u=t.sort,o=this.value;return r.rem.length&&(n={},r.visit(r.REM,function(t){n[t._id]=1}),o=o.filter(function(t){return!n[t._id]})),u?((t.modified("sort")||i.modified(u.fields))&&(o.sort(u),s=!0),a&&(o=e.merge(u,o,r.add.sort(u)))):a&&r.visit(r.ADD,function(t){o.push(t)}),this.modified(s),this.value=r.source=o,r},e.inherits(K,c);var Zt=e.inherits(B,A);Zt.transform=function(t,e){function i(e){return function(i){for(var n,r=J(u(i),t.case,a)||[],o=0,l=r.length;o<l;++o)s.test(n=r[o])||e(n)}}var n=this._parameterCheck(t,e),r=this._counts,a=this._match,s=this._stop,u=t.field,o=t.as||["text","count"],l=i(function(t){r[t]=1+(r[t]||0)}),d=i(function(t){r[t]-=1});return n?e.visit(e.SOURCE,l):(e.visit(e.ADD,l),e.visit(e.REM,d)),this._finish(e,o)},Zt._parameterCheck=function(t,e){var i=!1;return!t.modified("stopwords")&&this._stop||(this._stop=new RegExp("^"+(t.stopwords||"")+"$","i"),i=!0),!t.modified("pattern")&&this._match||(this._match=new RegExp(t.pattern||"[\\w']+","g"),i=!0),(t.modified("field")||e.modified(t.field.fields))&&(i=!0),i&&(this._counts={}),i},Zt._finish=function(t,e){var i,n,r,a=this._counts,u=this._tuples||(this._tuples={}),o=e[0],l=e[1],d=t.fork();for(i in a)n=u[i],r=a[i]||0,!n&&r?(u[i]=n=s({}),n[o]=i,n[l]=r,d.add.push(n)):0===r?(n&&d.rem.push(n),a[i]=null,u[i]=null):n[l]!==r&&(n[l]=r,d.mod.push(n));return d.modifies(e)},e.inherits($,A).transform=function(t,i){var n=i.fork(i.NO_SOURCE),r=this.value,a=t.as||["a","b"],s=a[0],u=a[1];return!r||i.changed(i.ADD_REM)||t.modified("as")||t.modified("filter")?(r&&(n.rem=r),n.add=this.value=H(i.source,s,u,t.filter||e.truthy)):n.mod=r,n.source=this.value,n.modifies(a)};var te={kde:n.randomKDE,mixture:n.randomMixture,normal:n.randomNormal,uniform:n.randomUniform},ee="distributions",ie="function",ne="field";e.inherits(X,A).transform=function(t,i){var n=i.fork(i.NO_SOURCE|i.NO_FIELDS);if(!this.value||i.changed()||t.modified()){var a=Q(t.distribution,Y(i)),u=t.method||"pdf";"pdf"!==u&&"cdf"!==u&&e.error("Invalid density method: "+u),t.extent||a.data||e.error("Missing density extent parameter."),u=a[u];var o=t.as||["value","density"],l=t.extent||r.extent(a.data()),d=(l[1]-l[0])/(t.steps||100),h=r.range(l[0],l[1]+d/2,d).map(function(t){var e={};return e[o[0]]=t,e[o[1]]=u(t),s(e)});this.value&&(n.rem=this.value),this.value=n.add=n.source=h}return n},e.inherits(Z,A).transform=function(t,e){var i=this.value,n=t.field,r=i[0],a=i[1],s=e.ADD;(e.changed()||e.modified(n.fields)||t.modified("field"))&&(s=e.SOURCE,r=1/0,a=-1/0),e.visit(s,function(t){var e=n(t);e<r&&(r=e),e>a&&(a=e)}),this.value=[r,a]};var re=e.inherits(tt,c);re.connect=function(t){return this.targets().add(t),t.source=this},re.add=function(t){this.value.add.push(t)},re.rem=function(t){this.value.rem.push(t)},re.mod=function(t){this.value.mod.push(t)},re.init=function(t){this.value.init(t,t.NO_SOURCE)},re.evaluate=function(){return this.value};var ae=e.inherits(et,A);ae.activate=function(t){this._targets[this._targets.active++]=t},ae.subflow=function(t,e,i,n){var r,a,s=this.value,u=s.hasOwnProperty(t)&&s[t];return u?u.value.stamp<i.stamp&&(u.init(i),this.activate(u)):(a=n||(a=this._group[t])&&a.tuple,u=(r=i.dataflow).add(new tt(i.fork(i.NO_SOURCE),this)).connect(e(r,t,a)),s[t]=u,this.activate(u)),u},ae.transform=function(t,e){function i(t){return r.subflow(t,s,e)}var n=e.dataflow,r=this,a=t.key,s=t.subflow,u=this._keys,o=t.modified("key");return this._group=t.group||{},this._targets.active=0,e.visit(e.REM,function(t){var e=u.get(t._id);void 0!==e&&(u.delete(t._id),i(e).rem(t))}),e.visit(e.ADD,function(t){var e=a(t);u.set(t._id,e),i(e).add(t)}),o||e.modified(a.fields)?e.visit(e.MOD,function(t){var e=u.get(t._id),n=a(t);e===n?i(n).mod(t):(u.set(t._id,n),i(e).rem(t),i(n).add(t))}):e.changed(e.MOD)&&e.visit(e.MOD,function(t){i(u.get(t._id)).mod(t)}),o&&e.visit(e.REFLOW,function(t){var e=u.get(t._id),n=a(t);e!==n&&(u.set(t._id,n),i(e).rem(t),i(n).add(t))}),u.empty>n.cleanThreshold&&n.runAfter(u.clean),e},e.inherits(it,c),e.inherits(rt,A).transform=function(t,e){function i(e){var i=l(e,t),n=r.get(e._id);i&&n?(r.delete(e._id),s.push(e)):i||n?d&&i&&!n&&o.push(e):(r.set(e._id,1),u.push(e))}var n=e.dataflow,r=this.value,a=e.fork(),s=a.add,u=a.rem,o=a.mod,l=t.expr,d=!0;return e.visit(e.REM,function(t){r.has(t._id)?r.delete(t._id):u.push(t)}),e.visit(e.ADD,function(e){l(e,t)?s.push(e):r.set(e._id,1)}),e.visit(e.MOD,i),t.modified()&&(d=!1,e.visit(e.REFLOW,i)),r.empty>n.cleanThreshold&&n.runAfter(r.clean),a},e.inherits(at,A).transform=function(t,e){function i(t){for(var e,i=r[t._id]=Array(c),n=0;n<c;++n)(e=i[n]=u(t))[d]=f[n],e[h]=s[n](t),p.add.push(e)}var n,r=this.value,a=t.modified("fields"),s=t.fields,l=t.as||["key","value"],d=l[0],h=l[1],f=s.map(st),c=s.length,m=e.stamp,p=e.fork(e.NO_SOURCE),v=0,g=0;if(a){for(n in r)p.rem.push.apply(p.rem,r[n]);r=this.value={},e.visit(e.SOURCE,i)}else{for(e.visit(e.ADD,i);v<c;++v)e.modified(s[v].fields)&&(g|=1<<v);g&&e.visit(e.MOD,function(t){for(var e,i=r[t._id],n=0;n<c;++n)g&1<<n&&((e=o(t,i[n],m))[d]=f[n],e[h]=s[n](t),p.mod.push(e))}),e.visit(e.REM,function(t){p.rem.push.apply(p.rem,r[t._id]),r[t._id]=null})}return p.modifies(l)},e.inherits(ut,A).transform=function(t,e){var i=t.expr,n=t.as,r=t.modified(),a=t.initonly?e.ADD:r?e.SOURCE:e.modified(i.fields)?e.ADD_MOD:e.ADD;return r&&(e=e.materialize().reflow(!0)),t.initonly||e.modifies(n),e.visit(a,function(e){e[n]=i(e,t)})},e.inherits(ot,A).transform=function(t,e){var i,n,r,a=this.value,u=e.fork(e.ALL),o=t.size-a.length,l=t.generator;if(o>0){for(i=[];--o>=0;)i.push(r=s(l(t))),a.push(r);u.add=u.add.length?u.materialize(u.ADD).add.concat(i):i}else n=a.slice(0,-o),u.rem=u.rem.length?u.materialize(u.REM).rem.concat(n):n,a=a.slice(-o);return u.source=this.value=a,u};var se={value:"value",median:r.median,mean:r.mean,min:r.min,max:r.max},ue=[];e.inherits(lt,A).transform=function(t,i){var n,r,a,u,o,l,d,h,f,c,m=i.fork(i.ALL),p=dt(t),v=ht(t),g=e.accessorName(t.field),_=e.accessorName(t.key),y=(t.groupby||[]).map(e.accessorName),x=ft(i.source,t.groupby,t.key,t.keyvals),k=[],w=this.value,D=x.domain.length;for(o=0,h=x.length;o<h;++o)for(a=(n=x[o]).values,r=NaN,d=0;d<D;++d)if(null==n[d]){for(u=x.domain[d],c={_impute:!0},l=0,f=a.length;l<f;++l)c[y[l]]=a[l];c[_]=u,c[g]=isNaN(r)?r=p(n,v):r,k.push(s(c))}return k.length&&(m.add=m.materialize(m.ADD).add.concat(k)),w.length&&(m.rem=m.materialize(m.REM).rem.concat(w)),this.value=k,m};var oe=e.inherits(ct,I);oe.transform=function(t,e){var i,n=this,r=t.modified();return n.value&&(r||e.modified(n._inputs))?(i=n.value=r?n.init(t):{},e.visit(e.SOURCE,function(t){n.add(t)})):(i=n.value=n.value||this.init(t),e.visit(e.REM,function(t){n.rem(t)}),e.visit(e.ADD,function(t){n.add(t)})),n.changes(),e.visit(e.SOURCE,function(t){o(i[n.cellkey(t)].tuple,t)}),e.reflow(r).modifies(this._outputs)},oe.changes=function(){var t,e,i=this._adds,n=this._mods;for(t=0,e=this._alen;t<e;++t)this.celltuple(i[t]),i[t]=null;for(t=0,e=this._mlen;t<e;++t)this.celltuple(n[t]),n[t]=null;this._alen=this._mlen=0},e.inherits(mt,c),e.inherits(vt,A).transform=function(t,i){var n,r,a=i,s=t.as,u=t.fields,o=t.index,l=t.values,d=null==t.default?null:t.default,h=t.modified(),f=h?i.SOURCE:i.ADD,c=u.length;return l?(r=l.length,c>1&&!s&&e.error('Multi-field lookup requires explicit "as" parameter.'),s&&s.length!==c*r&&e.error('The "as" parameter has too few output field names.'),s=s||l.map(e.accessorName),n=function(t){for(var e,i,n=0,a=0;n<c;++n)if(null==(i=o.get(u[n](t))))for(e=0;e<r;++e,++a)t[s[a]]=d;else for(e=0;e<r;++e,++a)t[s[a]]=l[e](i)}):(s||e.error("Missing output field names."),n=function(t){for(var e,i=0;i<c;++i)e=o.get(u[i](t)),t[s[i]]=null==e?d:e}),h?a=i.reflow(!0):f|=u.some(function(t){return i.modified(t.fields)})?i.MOD:0,i.visit(f,n),a.modifies(s)},e.inherits(gt,c),e.inherits(yt,c),e.inherits(kt,A),kt.prototype.transform=function(t,e){return this.modified(t.modified()),this.value=t,e.fork(e.NO_SOURCE|e.NO_FIELDS)},e.inherits(wt,et).transform=function(t,i){var n=this,r=t.subflow,a=t.field;return(t.modified("field")||a&&i.modified(e.accessorFields(a)))&&e.error("PreFacet does not support field modification."),this._targets.active=0,i.visit(i.MOD,function(t){var e=n.subflow(t._id,r,i,t);a?a(t).forEach(function(t){e.mod(t)}):e.mod(t)}),i.visit(i.ADD,function(t){var e=n.subflow(t._id,r,i,t);a?a(t).forEach(function(t){e.add(s(t))}):e.add(t)}),i.visit(i.REM,function(t){var e=n.subflow(t._id,r,i,t);a?a(t).forEach(function(t){e.rem(t)}):e.rem(t)}),i},e.inherits(Dt,A).transform=function(t,e){return this.value=t.value,t.modified("value")?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation},e.inherits(Ot,A).transform=function(t,i){i.source||e.error("Rank transform requires an upstream data source.");var n,r=t.normalize,a=t.field,s=t.as||"rank",u={},o=-1;return a?(i.visit(i.SOURCE,function(t){var e=a(t);null==u[e]&&(u[e]=++o)}),i.visit(i.SOURCE,r&&--o?function(t){t[s]=u[a(t)]/o}:function(t){t[s]=u[a(t)]})):(o+=i.source.length,n=-1,i.visit(i.SOURCE,r&&o?function(t){t[s]=++n/o}:function(t){t[s]=++n})),i.reflow(t.modified()).modifies(s)},e.inherits(qt,A).transform=function(t,e){var i,n;return this.value?n=this.value:(i=e=e.addAll(),n=this.value={}),t.derive&&(i=e.fork(),e.visit(e.ADD,function(t){var e=u(t);n[t._id]=e,i.add.push(e)}),e.visit(e.MOD,function(t){i.mod.push(o(t,n[t._id]))}),e.visit(e.REM,function(t){i.rem.push(n[t._id]),n[t._id]=null})),i},e.inherits(Et,A).transform=function(t,e){function i(t){var e,i;s.length<a?s.push(t):(i=~~(u*Math.random()))<s.length&&i>=o&&(e=s[i],l[e._id]&&n.rem.push(e),s[i]=t),++u}var n=e.fork(),r=t.modified("size"),a=t.size,s=this.value,u=this.count,o=0,l=s.reduce(function(t,e){return t[e._id]=1,t},{});if(e.rem.length&&(e.visit(e.REM,function(t){l[t._id]&&(l[t._id]=-1,n.rem.push(t)),--u}),s=s.filter(function(t){return-1!==l[t._id]})),(e.rem.length||r)&&s.length<a&&e.source&&(o=u=s.length,e.visit(e.SOURCE,function(t){l[t._id]||i(t)}),o=-1),r&&s.length>a){for(var d=0,h=s.length-a;d<h;++d)l[s[d]._id]=-1,n.rem.push(s[d]);s=s.slice(h)}return e.mod.length&&e.visit(e.MOD,function(t){l[t._id]&&n.mod.push(t)}),e.add.length&&e.visit(e.ADD,i),(e.add.length||o<0)&&(n.add=s.filter(function(t){return!l[t._id]})),this.count=u,this.value=n.source=s,n},e.inherits(bt,A).transform=function(t,e){if(!this.value||t.modified()){var i=e.materialize().fork(e.MOD);return i.rem=this.value?e.rem.concat(this.value):e.rem,i.source=this.value=r.range(t.start,t.stop,t.step||1).map(s),i.add=e.add.concat(this.value),i}},e.inherits(Ft,A).transform=function(t,e){return this.value=e.source,e.changed()?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation},e.inherits(At,A).transform=function(t,e){function i(t){a.set(r(t),t)}var n=e.dataflow,r=t.field,a=this.value,s=!0;return t.modified("field")||e.modified(r.fields)?(a.clear(),e.visit(e.SOURCE,i)):e.changed()?(e.visit(e.REM,function(t){a.delete(r(t))}),e.visit(e.ADD,i)):s=!1,this.modified(s),a.empty>n.cleanThreshold&&n.runAfter(a.clean),e.fork()},e.inherits(Rt,A).transform=function(t,e){(!this.value||t.modified("field")||t.modified("sort")||e.changed()||t.sort&&e.modified(t.sort.fields))&&(this.value=(t.sort?e.source.slice().sort(t.sort):e.source).map(t.field))};var le={type:"Aggregate",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"fields",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:["count","valid","missing","distinct","sum","mean","average","variance","variancep","stdev","stdevp","stderr","median","q1","q3","ci0","ci1","min","max","argmin","argmax"]},{name:"as",type:"string",array:!0},{name:"drop",type:"boolean",default:!0},{name:"cross",type:"boolean",default:!1},{name:"key",type:"field"}]},de={type:"Bin",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"anchor",type:"number"},{name:"maxbins",type:"number",default:20},{name:"base",type:"number",default:10},{name:"divide",type:"number",array:!0,default:[5,2]},{name:"extent",type:"number",array:!0,length:2,required:!0},{name:"step",type:"number"},{name:"steps",type:"number",array:!0},{name:"minstep",type:"number",default:0},{name:"nice",type:"boolean",default:!0},{name:"name",type:"string"},{name:"as",type:"string",array:!0,length:2,default:["bin0","bin1"]}]},he={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]},fe={type:"CountPattern",metadata:{generates:!0,changes:!0},params:[{name:"field",type:"field",required:!0},{name:"case",type:"enum",values:["upper","lower","mixed"],default:"mixed"},{name:"pattern",type:"string",default:'[\\w"]+'},{name:"stopwords",type:"string",default:""},{name:"as",type:"string",array:!0,length:2,default:["text","count"]}]},ce={type:"Cross",metadata:{source:!0,generates:!0,changes:!0},params:[{name:"filter",type:"expr"},{name:"as",type:"string",array:!0,length:2,default:["a","b"]}]},me=[{key:{function:"normal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"uniform"},params:[{name:"min",type:"number",default:0},{name:"max",type:"number",default:1}]},{key:{function:"kde"},params:[{name:"field",type:"field",required:!0},{name:"from",type:"data"},{name:"bandwidth",type:"number",default:0}]}],pe={key:{function:"mixture"},params:[{name:"distributions",type:"param",array:!0,params:me},{name:"weights",type:"number",array:!0}]},ve={type:"Density",metadata:{generates:!0,source:!0},params:[{name:"extent",type:"number",array:!0,length:2},{name:"steps",type:"number",default:100},{name:"method",type:"string",default:"pdf",values:["pdf","cdf"]},{name:"distribution",type:"param",params:me.concat(pe)},{name:"as",type:"string",array:!0,default:["value","density"]}]},ge={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]},_e={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]},ye={type:"Fold",metadata:{generates:!0,changes:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0,length:2,default:["key","value"]}]},xe={type:"Formula",metadata:{modifies:!0},params:[{name:"expr",type:"expr",required:!0},{name:"as",type:"string",required:!0},{name:"initonly",type:"boolean"}]},ke={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"key",type:"field",required:!0},{name:"keyvals",array:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]},we={type:"JoinAggregate",metadata:{modifies:!0},params:[{name:"groupby",type:"field",array:!0},{name:"fields",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:["count","valid","missing","distinct","sum","mean","average","variance","variancep","stdev","stdevp","stderr","median","q1","q3","ci0","ci1","min","max","argmin","argmax"]},{name:"as",type:"string",array:!0},{name:"key",type:"field"}]},De={type:"Lookup",metadata:{modifies:!0},params:[{name:"index",type:"index",params:[{name:"from",type:"data",required:!0},{name:"key",type:"field",required:!0}]},{name:"values",type:"field",array:!0},{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0},{name:"default",default:null}]},Oe={type:"Rank",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"normalize",type:"boolean",default:!1},{name:"as",type:"string",default:"rank"}]},qe={type:"Sample",metadata:{source:!0,changes:!0},params:[{name:"size",type:"number",default:1e3}]},Ee={type:"Sequence",metadata:{generates:!0,source:!0},params:[{name:"start",type:"number",required:!0},{name:"stop",type:"number",required:!0},{name:"step",type:"number",default:1}],output:["value"]};R(le,I),R(de,W),R(he,G),R(fe,B),R(ce,$),R(ve,X),R(ge,Z),R(_e,rt),R(ye,at),R(xe,ut),R(ke,lt),R(we,ct),R(De,vt),R(Oe,Ot),R(qe,Et),R(Ee,bt),S("Compare",K),S("Facet",et),S("Field",it),S("Generate",ot),S("Key",mt),S("MultiExtent",gt),S("MultiValues",yt),S("Params",kt),S("PreFacet",wt),S("Proxy",Dt),S("Relay",qt),S("Sieve",Ft),S("Subflow",tt),S("TupleIndex",At),S("Values",Rt),t.UniqueList=a,t.changeset=h,t.isChangeSet=d,t.Dataflow=b,t.EventStream=p,t.Parameters=f,t.Pulse=y,t.MultiPulse=D,t.Operator=c,t.Transform=A,t.ingest=s,t.tupleid=function(t){return t._id},t.definition=M,t.definitions=$t,t.register=R,t.transform=S,t.transforms=Jt,Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -6,4 +6,5 @@ export default { | ||
{ "name": "field", "type": "field", "required": true }, | ||
{ "name": "key", "type": "field", "required": true }, | ||
{ "name": "keyvals", "array": true }, | ||
{ "name": "groupby", "type": "field", "array": true }, | ||
{ "name": "orderby", "type": "field", "array": true }, | ||
{ "name": "method", "type": "enum", "default": "value", | ||
@@ -10,0 +11,0 @@ "values": ["value", "mean", "median", "max", "min"] }, |
{ | ||
"name": "vega-dataflow", | ||
"version": "2.0.0-beta.31", | ||
"version": "2.0.0", | ||
"description": "Reactive dataflow processing.", | ||
@@ -33,3 +33,3 @@ "keywords": [ | ||
"d3-array": "1", | ||
"vega-loader": ">=2.0.0-beta", | ||
"vega-loader": "2", | ||
"vega-statistics": "1", | ||
@@ -39,7 +39,7 @@ "vega-util": "^1.1" | ||
"devDependencies": { | ||
"eslint": "2", | ||
"rollup": "0.36", | ||
"eslint": "4", | ||
"rollup": "0.43", | ||
"tape": "4", | ||
"uglify-js": "2" | ||
"uglify-js": "3" | ||
} | ||
} |
@@ -21,1 +21,4 @@ # vega-dataflow | ||
group-by aggregation, and cross-stream lookup operations. | ||
For more information about data stream transforms, see the | ||
[Vega transform documentation](https://vega.github.io/vega/docs/transforms/). |
@@ -31,4 +31,9 @@ import {ingest} from './Tuple'; | ||
var m = {field: field, value: constant(value)}; | ||
if (isFunction(t)) m.filter = t, modp.push(m); | ||
else m.tuple = t, mod.push(m); | ||
if (isFunction(t)) { | ||
m.filter = t; | ||
modp.push(m); | ||
} else { | ||
m.tuple = t; | ||
mod.push(m); | ||
} | ||
return this; | ||
@@ -35,0 +40,0 @@ }, |
@@ -61,3 +61,8 @@ import add from './dataflow/add'; | ||
prototype.loader = function(_) { | ||
return arguments.length ? (this._loader = _, this) : this._loader; | ||
if (arguments.length) { | ||
this._loader = _; | ||
return this; | ||
} else { | ||
return this._loader; | ||
} | ||
}; | ||
@@ -64,0 +69,0 @@ |
@@ -22,9 +22,20 @@ import Operator from '../Operator'; | ||
var shift = 1, | ||
op = (init instanceof Operator) ? init | ||
: init && init.prototype instanceof Operator ? new init() | ||
: isFunction(init) ? new Operator(null, init) | ||
: (shift = 0, new Operator(init, update)); | ||
op; | ||
if (init instanceof Operator) { | ||
op = init; | ||
} else if (init && init.prototype instanceof Operator) { | ||
op = new init(); | ||
} else if (isFunction(init)) { | ||
op = new Operator(null, init); | ||
} else { | ||
shift = 0; | ||
op = new Operator(init, update); | ||
} | ||
this.rank(op); | ||
if (shift) react = params, params = update; | ||
if (shift) { | ||
react = params; | ||
params = update; | ||
} | ||
if (params) this.connect(op, op.parameters(params, react)); | ||
@@ -31,0 +42,0 @@ this.touch(op); |
@@ -28,3 +28,3 @@ import {read} from 'vega-loader'; | ||
} | ||
} | ||
}; | ||
@@ -31,0 +31,0 @@ return (df._pending = pending); |
@@ -35,3 +35,4 @@ import Operator from '../Operator'; | ||
var fn = source instanceof Operator ? onOperator : onStream; | ||
return fn(this, source, target, update, params, options), this; | ||
fn(this, source, target, update, params, options); | ||
return this; | ||
} | ||
@@ -51,5 +52,5 @@ | ||
func = function(e) { | ||
var t = target(e), | ||
v = (op.evaluate(e), op.value); | ||
isChangeSet(v) ? df.pulse(t, v, options) : df.update(t, v, opt); | ||
var v, t = target(e); | ||
op.evaluate(e); | ||
isChangeSet(v = op.value) ? df.pulse(t, v, options) : df.update(t, v, opt); | ||
}; | ||
@@ -56,0 +57,0 @@ } else { |
@@ -49,3 +49,4 @@ import UniqueList from './util/UniqueList'; | ||
if (!arguments.length) return !!this._consume; | ||
return (this._consume = !!_, this); | ||
this._consume = !!_; | ||
return this; | ||
}; | ||
@@ -71,3 +72,4 @@ | ||
var s = stream(filter); | ||
return (this.targets().add(s), s); | ||
this.targets().add(s); | ||
return s; | ||
}; | ||
@@ -77,3 +79,4 @@ | ||
var s = stream(null, apply); | ||
return (this.targets().add(s), s); | ||
this.targets().add(s); | ||
return s; | ||
}; | ||
@@ -96,3 +99,8 @@ | ||
var now = Date.now(); | ||
return (now - t) > pause ? (t = now, 1) : 0; | ||
if ((now - t) > pause) { | ||
t = now; | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
}); | ||
@@ -99,0 +107,0 @@ }; |
@@ -62,3 +62,8 @@ import Parameters from './Parameters'; | ||
prototype.set = function(value) { | ||
return this.value !== value ? (this.value = value, 1) : 0; | ||
if (this.value !== value) { | ||
this.value = value; | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
}; | ||
@@ -208,4 +213,12 @@ | ||
if (pulse.stamp <= this.stamp) return pulse.StopPropagation; | ||
var rv = this.skip() ? (this.skip(false), 0) : this.evaluate(pulse); | ||
return this.stamp = pulse.stamp, this.pulse = rv || pulse; | ||
var rv; | ||
if (this.skip()) { | ||
this.skip(false); | ||
rv = 0; | ||
} else { | ||
rv = this.evaluate(pulse); | ||
} | ||
this.stamp = pulse.stamp; | ||
this.pulse = rv; | ||
return rv || pulse; | ||
}; |
@@ -76,3 +76,4 @@ import {isArray} from 'vega-util'; | ||
prototype.clear = function() { | ||
return this[CACHE] = {}, this; | ||
this[CACHE] = {}; | ||
return this; | ||
}; |
@@ -141,4 +141,9 @@ import {array, isArray, visitArray} from 'vega-util'; | ||
var p = this; | ||
return (!this.source || this.source.length === this.add.length) ? p | ||
: (p = new Pulse(this.dataflow).init(this), p.add = p.source, p); | ||
if (!this.source || this.source.length === this.add.length) { | ||
return p; | ||
} else { | ||
p = new Pulse(this.dataflow).init(this); | ||
p.add = p.source; | ||
return p; | ||
} | ||
}; | ||
@@ -163,9 +168,37 @@ | ||
p.encode = src.encode; | ||
if (src.fields && !(flags & NO_FIELDS)) p.fields = src.fields; | ||
p.add = (flags & ADD) ? (p.addF = src.addF, src.add) : (p.addF = null, []); | ||
p.rem = (flags & REM) ? (p.remF = src.remF, src.rem) : (p.remF = null, []); | ||
p.mod = (flags & MOD) ? (p.modF = src.modF, src.mod) : (p.modF = null, []); | ||
p.source = (flags & NO_SOURCE) | ||
? (p.srcF = null, null) | ||
: (p.srcF = src.srcF, src.source); | ||
if (flags & ADD) { | ||
p.addF = src.addF; | ||
p.add = src.add; | ||
} else { | ||
p.addF = null; | ||
p.add = []; | ||
} | ||
if (flags & REM) { | ||
p.remF = src.remF; | ||
p.rem = src.rem; | ||
} else { | ||
p.remF = null; | ||
p.rem = []; | ||
} | ||
if (flags & MOD) { | ||
p.modF = src.modF; | ||
p.mod = src.mod; | ||
} else { | ||
p.modF = null; | ||
p.mod = []; | ||
} | ||
if (flags & NO_SOURCE) { | ||
p.srcF = null; | ||
p.source = null; | ||
} else { | ||
p.srcF = src.srcF; | ||
p.source = src.source; | ||
} | ||
return p; | ||
@@ -172,0 +205,0 @@ }; |
@@ -13,9 +13,17 @@ export var transforms = {}; | ||
type = type && type.toLowerCase(); | ||
return arguments.length > 1 ? (definitions[type] = def, this) | ||
: definitions.hasOwnProperty(type) ? definitions[type] : null; | ||
if (arguments.length > 1) { | ||
definitions[type] = def; | ||
return this; | ||
} else { | ||
return definitions.hasOwnProperty(type) ? definitions[type] : null; | ||
} | ||
} | ||
export function transform(type, constructor) { | ||
return arguments.length > 1 ? (transforms[type] = constructor, this) | ||
: transforms.hasOwnProperty(type) ? transforms[type] : null; | ||
if (arguments.length > 1) { | ||
transforms[type] = constructor; | ||
return this; | ||
} else { | ||
return transforms.hasOwnProperty(type) ? transforms[type] : null; | ||
} | ||
} |
@@ -28,5 +28,15 @@ import Operator from './Operator'; | ||
if (pulse.stamp <= this.stamp) return pulse.StopPropagation; | ||
var rv = (this.skip() ? (this.skip(false), 0) : this.evaluate(pulse)) || pulse; | ||
var rv; | ||
if (this.skip()) { | ||
this.skip(false); | ||
} else { | ||
rv = this.evaluate(pulse); | ||
} | ||
rv = rv || pulse; | ||
if (rv !== pulse.StopPropagation) this.pulse = rv; | ||
return this.stamp = pulse.stamp, rv; | ||
this.stamp = pulse.stamp; | ||
return rv; | ||
}; | ||
@@ -33,0 +43,0 @@ |
@@ -136,4 +136,6 @@ import Transform from '../../Transform'; | ||
this._dnames = this._dims.map(function(d) { | ||
var dname = accessorName(d) | ||
return (inputVisit(d), outputs.push(dname), dname); | ||
var dname = accessorName(d); | ||
inputVisit(d); | ||
outputs.push(dname); | ||
return dname; | ||
}); | ||
@@ -140,0 +142,0 @@ this.cellkey = _.key ? _.key |
@@ -155,3 +155,6 @@ import {extend, identity} from 'vega-util'; | ||
collect, | ||
agg.reduce(function(m, a) { return (m[a.name] = a, m); }, {}) | ||
agg.reduce(function(m, a) { | ||
m[a.name] = a; | ||
return m; | ||
}, {}) | ||
); | ||
@@ -158,0 +161,0 @@ var values = [], key; |
@@ -25,6 +25,11 @@ import Transform from '../Transform'; | ||
b1 = as[1], | ||
flag = _.modified() ? (pulse = pulse.reflow(true), pulse.SOURCE) | ||
: pulse.modified(accessorFields(_.field)) ? pulse.ADD_MOD | ||
: pulse.ADD; | ||
flag; | ||
if (_.modified()) { | ||
pulse = pulse.reflow(true); | ||
flag = pulse.SOURCE; | ||
} else { | ||
flag = pulse.modified(accessorFields(_.field)) ? pulse.ADD_MOD : pulse.ADD; | ||
} | ||
pulse.visit(flag, function(t) { | ||
@@ -63,5 +68,8 @@ var v = bins(t); | ||
var v = field(t); | ||
return v == null ? null | ||
: (v = Math.max(start, Math.min(+v, stop - step)), | ||
start + step * Math.floor((v - start) / step)); | ||
if (v == null) { | ||
return null; | ||
} else { | ||
v = Math.max(start, Math.min(+v, stop - step)); | ||
return start + step * Math.floor((v - start) / step); | ||
} | ||
}; | ||
@@ -68,0 +76,0 @@ |
@@ -23,8 +23,7 @@ import Transform from '../Transform'; | ||
data = this.value, | ||
push = function(t) { data.push(t); }, | ||
n = 0, map; | ||
map; | ||
if (out.rem.length) { // build id map and filter data array | ||
map = {}; | ||
out.visit(out.REM, function(t) { map[t._id] = 1; ++n; }); | ||
out.visit(out.REM, function(t) { map[t._id] = 1; }); | ||
data = data.filter(function(t) { return !map[t._id]; }); | ||
@@ -45,3 +44,3 @@ } | ||
// no sort, so simply add new tuples | ||
out.visit(out.ADD, push); | ||
out.visit(out.ADD, function(t) { data.push(t); }); | ||
} | ||
@@ -48,0 +47,0 @@ |
@@ -76,3 +76,3 @@ import Transform from '../Transform'; | ||
return init; | ||
} | ||
}; | ||
@@ -79,0 +79,0 @@ prototype._finish = function(pulse, as) { |
@@ -36,3 +36,4 @@ import Transform from '../Transform'; | ||
return out.source = this.value, out.modifies(as); | ||
out.source = this.value; | ||
return out.modifies(as); | ||
}; | ||
@@ -39,0 +40,0 @@ |
@@ -23,4 +23,9 @@ import Transform from '../Transform'; | ||
* accessors to determine series within which to perform imputation. | ||
* @param {Array<function(object): *>} [params.orderby] - An array of | ||
* accessors to determine the ordering within a series. | ||
* @param {function(object): *} params.key - An accessor for a key value. | ||
* Each key value should be unique within a group. New tuples will be | ||
* imputed for any key values that are not found within a group. | ||
* @param {Array<*>} [params.keyvals] - Optional array of required key | ||
* values. New tuples will be imputed for any key values that are not | ||
* found within a group. In addition, these values will be automatically | ||
* augmented with the key values observed in the input data. | ||
* @param {string} [method='value'] - The imputation method to use. One of | ||
@@ -60,9 +65,9 @@ * 'value', 'mean', 'median', 'max', 'min'. | ||
fName = accessorName(_.field), | ||
gNames = _.groupby.map(accessorName), | ||
oNames = _.orderby.map(accessorName), | ||
groups = partition(pulse.source, _.groupby, _.orderby), | ||
kName = accessorName(_.key), | ||
gNames = (_.groupby || []).map(accessorName), | ||
groups = partition(pulse.source, _.groupby, _.key, _.keyvals), | ||
curr = [], | ||
prev = this.value, | ||
m = groups.domain.length, | ||
group, value, gVals, oVals, g, i, j, l, n, t; | ||
group, value, gVals, kVal, g, i, j, l, n, t; | ||
@@ -77,7 +82,7 @@ for (g=0, l=groups.length; g<l; ++g) { | ||
if (group[j] != null) continue; | ||
oVals = groups.domain[j]; | ||
kVal = groups.domain[j]; | ||
t = {_impute: true}; | ||
for (i=0, n=gVals.length; i<n; ++i) t[gNames[i]] = gVals[i]; | ||
for (i=0, n=oVals.length; i<n; ++i) t[oNames[i]] = oVals[i]; | ||
t[kName] = kVal; | ||
t[fName] = isNaN(value) ? (value = impute(group, field)) : value; | ||
@@ -97,16 +102,17 @@ | ||
function partition(data, groupby, orderby) { | ||
function partition(data, groupby, key, keyvals) { | ||
var get = function(f) { return f(t); }, | ||
groups = [], | ||
domain = [], | ||
oMap = {}, oVals, oKey, | ||
domain = keyvals ? keyvals.slice() : [], | ||
kMap = {}, | ||
gMap = {}, gVals, gKey, | ||
group, i, j, n, t; | ||
group, i, j, k, n, t; | ||
domain.forEach(function(k, i) { kMap[k] = i + 1; }); | ||
for (i=0, n=data.length; i<n; ++i) { | ||
t = data[i]; | ||
k = key(t); | ||
j = kMap[k] || (kMap[k] = domain.push(k)); | ||
oKey = (oVals = orderby.map(get)) + ''; | ||
j = oMap[oKey] || (oMap[oKey] = domain.push(oVals)); | ||
gKey = (gVals = groupby ? groupby.map(get) : Empty) + ''; | ||
@@ -121,3 +127,4 @@ if (!(group = gMap[gKey])) { | ||
return (groups.domain = domain, groups); | ||
groups.domain = domain; | ||
return groups; | ||
} |
@@ -22,5 +22,11 @@ import Transform from '../Transform'; | ||
prototype.transform = function(_, pulse) { | ||
var out, | ||
lut = this.value || (out = pulse = pulse.addAll(), this.value = {}); | ||
var out, lut; | ||
if (this.value) { | ||
lut = this.value; | ||
} else { | ||
out = pulse = pulse.addAll(); | ||
lut = this.value = {}; | ||
} | ||
if (_.derive) { | ||
@@ -27,0 +33,0 @@ out = pulse.fork(); |
@@ -25,3 +25,6 @@ import Transform from '../Transform'; | ||
cap = 0, | ||
map = res.reduce(function(m, t) { return (m[t._id] = 1, m); }, {}); | ||
map = res.reduce(function(m, t) { | ||
m[t._id] = 1; | ||
return m; | ||
}, {}); | ||
@@ -28,0 +31,0 @@ // sample reservoir update function |
@@ -64,3 +64,4 @@ var TUPLE_ID = 1; | ||
function replace(t, d) { | ||
return d._id = t._id, d; | ||
d._id = t._id; | ||
return d; | ||
} | ||
@@ -67,0 +68,0 @@ |
@@ -13,3 +13,4 @@ export default function Heap(comparator) { | ||
prototype.clear = function() { | ||
return (this.nodes = [], this); | ||
this.nodes = []; | ||
return this; | ||
}; | ||
@@ -16,0 +17,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
303349
7829
2
24
+ Addedd3-collection@1.0.7(transitive)
+ Addedd3-dispatch@1.0.6(transitive)
+ Addedd3-dsv@1.2.0(transitive)
+ Addedd3-request@1.0.6(transitive)
+ Addedd3-time@1.1.0(transitive)
+ Addedd3-time-format@2.3.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedvega-loader@2.1.0(transitive)
+ Addedxmlhttprequest@1.8.0(transitive)
- Removedcommander@7.2.0(transitive)
- Removedd3-dsv@3.0.1(transitive)
- Removedd3-format@3.1.0(transitive)
- Removedd3-time@3.1.0(transitive)
- Removedd3-time-format@4.1.0(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedvega-format@1.1.2(transitive)
- Removedvega-loader@4.5.2(transitive)
- Removedvega-time@2.1.2(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
Updatedvega-loader@2