Files
wakapi-readme-stats/node_modules/vega-view-transforms/build/vega-view-transforms.min.js
2020-07-28 00:48:25 +05:30

1 line
15 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-dataflow"),require("vega-scenegraph"),require("vega-util")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-scenegraph","vega-util"],t):t(((e=e||self).vega=e.vega||{},e.vega.transforms={}),e.vega,e.vega,e.vega)}(this,(function(e,t,n,o){"use strict";const r="top",a="left",i="right",s="end",u="row";function c(e){t.Transform.call(this,null,e)}function l(e,t,n){return t(e.bounds.clear(),e,n)}o.inherits(c,t.Transform).transform=function(e,t){var o,r=t.dataflow,a=e.mark,i=a.marktype,s=n.Marks[i],u=s.bound,c=a.bounds;if(s.nested)a.items.length&&r.dirty(a.items[0]),c=l(a,u),a.items.forEach((function(e){e.bounds.clear().union(c)}));else if("group"===i||e.modified())switch(t.visit(t.MOD,e=>r.dirty(e)),c.clear(),a.items.forEach(e=>c.union(l(e,u))),a.role){case"axis":case"legend":case"title":t.reflow()}else o=t.changed(t.REM),t.visit(t.ADD,e=>{c.union(l(e,u))}),t.visit(t.MOD,e=>{o=o||c.alignsWith(e.bounds),r.dirty(e),c.union(l(e,u))}),o&&(c.clear(),a.items.forEach(e=>c.union(e.bounds)));return n.boundClip(a),t.modifies("bounds")};function d(e){t.Transform.call(this,0,e)}function h(e){t.Transform.call(this,null,e)}function f(e){t.Transform.call(this,null,e)}d.Definition={type:"Identifier",metadata:{modifies:!0},params:[{name:"as",type:"string",required:!0}]},o.inherits(d,t.Transform).transform=function(e,t){var n=function(e){var t=e._signals[":vega_identifier:"];t||(e._signals[":vega_identifier:"]=t=e.add(0));return t}(t.dataflow),o=n.value,r=e.as;return t.visit(t.ADD,e=>{e[r]||(e[r]=++o)}),n.set(this.value=o),t},o.inherits(h,t.Transform).transform=function(e,t){var o=this.value;o||((o=t.dataflow.scenegraph().mark(e.markdef,function(e){var t=e.groups,n=e.parent;return t&&1===t.size?t.get(Object.keys(t.object)[0]):t&&n?t.lookup(n):null}(e),e.index)).group.context=e.context,e.context.group||(e.context.group=o.group),o.source=this.source,o.clip=e.clip,o.interactive=e.interactive,this.value=o);var r="group"===o.marktype?n.GroupItem:n.Item;return t.visit(t.ADD,e=>r.call(e,o)),(e.modified("clip")||e.modified("interactive"))&&(o.clip=e.clip,o.interactive=!!e.interactive,o.zdirty=!0,t.reflow()),o.items=t.source,t};var m=o.inherits(f,t.Transform),b={parity:e=>e.filter((e,t)=>t%2?e.opacity=0:1),greedy:(e,t)=>{var n;return e.filter((e,o)=>o&&y(n.bounds,e.bounds,t)?e.opacity=0:(n=e,1))}};function y(e,t,n){return n>Math.max(t.x1-e.x2,e.x1-t.x2,t.y1-e.y2,e.y1-t.y2)}function x(e,t){for(var n,o=1,r=e.length,a=e[0].bounds;o<r;a=n,++o)if(y(a,n=e[o].bounds,t))return!0}function g(e){var t=e.bounds;return t.width()>1&&t.height()>1}function p(e){return e.forEach(e=>e.opacity=1),e}function w(e,t){return e.reflow(t.modified()).modifies("opacity")}function k(e){t.Transform.call(this,null,e)}m.transform=function(e,t){var a,i,s,u=b[e.method]||b.parity,c=t.materialize(t.SOURCE).source,l=e.separation||0;if(c&&c.length){if(!e.method)return e.modified("method")&&(p(c),t=w(t,e)),t;if((c=c.filter(g)).length){if(e.sort&&(c=c.slice().sort(e.sort)),a=p(c),t=w(t,e),a.length>=3&&x(a,l)){do{a=u(a,l)}while(a.length>=3&&x(a,l));a.length<3&&!o.peek(c).opacity&&(a.length>1&&(o.peek(a).opacity=0),o.peek(c).opacity=1)}var d,h,f,m,y;return e.boundScale&&e.boundTolerance>=0&&(d=e.boundScale,h=e.boundOrient,f=+e.boundTolerance,m=d.range(),y=new n.Bounds,h===r||"bottom"===h?y.set(m[0],-1/0,m[1],1/0):y.set(-1/0,m[0],1/0,m[1]),y.expand(f||1),i=e=>y.encloses(e.bounds),c.forEach(e=>{i(e)||(e.opacity=0)})),s=a[0].mark.bounds.clear(),c.forEach(e=>{e.opacity&&s.union(e.bounds)}),t}}},o.inherits(k,t.Transform).transform=function(e,t){var n=t.dataflow;if(t.visit(t.ALL,e=>n.dirty(e)),t.fields&&t.fields.zindex){var o=t.source&&t.source[0];o&&(o.mark.zdirty=!0)}};const v=new n.Bounds;function M(e,t,n){return e[t]===n?0:(e[t]=n,1)}function E(e){var t=e.items[0].orient;return t===a||t===i}function T(e,t,o,s){var u,c,l=t.items[0],d=l.datum,h=null!=l.translate?l.translate:.5,f=l.orient,m=function(e){var t=+e.grid;return[e.ticks?t++:-1,e.labels?t++:-1,t+ +e.domain]}(d),b=l.range,y=l.offset,x=l.position,g=l.minExtent,p=l.maxExtent,w=d.title&&l.items[m[2]].items[0],k=l.titlePadding,E=l.bounds,T=w&&n.multiLineOffset(w),A=0,z=0;switch(v.clear().union(E),E.clear(),(u=m[0])>-1&&E.union(l.items[u].bounds),(u=m[1])>-1&&E.union(l.items[u].bounds),f){case r:A=x||0,z=-y,c=Math.max(g,Math.min(p,-E.y1)),E.add(0,-c).add(b,0),w&&_(e,w,c,k,T,0,-1,E);break;case a:A=-y,z=x||0,c=Math.max(g,Math.min(p,-E.x1)),E.add(-c,0).add(0,b),w&&_(e,w,c,k,T,1,-1,E);break;case i:A=o+y,z=x||0,c=Math.max(g,Math.min(p,E.x2)),E.add(0,0).add(c,b),w&&_(e,w,c,k,T,1,1,E);break;case"bottom":A=x||0,z=s+y,c=Math.max(g,Math.min(p,E.y2)),E.add(0,0).add(b,c),w&&_(e,w,c,k,0,0,1,E);break;default:A=l.x,z=l.y}return n.boundStroke(E.translate(A,z),l),M(l,"x",A+h)|M(l,"y",z+h)&&(l.bounds=v,e.dirty(l),l.bounds=E,e.dirty(l)),l.mark.bounds.clear().union(E)}function _(e,t,n,o,r,a,i,s){const u=t.bounds;if(t.auto){const s=i*(n+r+o);let c=0,l=0;e.dirty(t),a?c=(t.x||0)-(t.x=s):l=(t.y||0)-(t.y=s),t.mark.bounds.clear().union(u.translate(-c,-l)),e.dirty(t)}s.union(u)}const A=(e,t)=>Math.floor(Math.min(e,t)),z=(e,t)=>Math.ceil(Math.max(e,t));function B(e){return(new n.Bounds).set(0,0,e.width||0,e.height||0)}function D(e){var t=e.bounds.clone();return t.empty()?t.set(0,0,0,0):t.translate(-(e.x||0),-(e.y||0))}function O(e,t,n){var r=o.isObject(e)?e[t]:e;return null!=r?r:void 0!==n?n:0}function j(e){return e<0?Math.ceil(-e):0}function q(e,t,n){var o,r,a,i,c,l,d,h,f,m,b,y=!n.nodirty,x="flush"===n.bounds?B:D,g=v.set(0,0,0,0),p=O(n.align,"column"),w=O(n.align,u),k=O(n.padding,"column"),M=O(n.padding,u),E=n.columns||t.length,T=E<=0?1:Math.ceil(t.length/E),_=t.length,A=Array(_),z=Array(E),q=0,S=Array(_),L=Array(T),I=0,P=Array(_),C=Array(_),F=Array(_);for(r=0;r<E;++r)z[r]=0;for(r=0;r<T;++r)L[r]=0;for(r=0;r<_;++r)l=t[r],c=F[r]=x(l),l.x=l.x||0,P[r]=0,l.y=l.y||0,C[r]=0,a=r%E,i=~~(r/E),q=Math.max(q,d=Math.ceil(c.x2)),I=Math.max(I,h=Math.ceil(c.y2)),z[a]=Math.max(z[a],d),L[i]=Math.max(L[i],h),A[r]=k+j(c.x1),S[r]=M+j(c.y1),y&&e.dirty(t[r]);for(r=0;r<_;++r)r%E==0&&(A[r]=0),r<E&&(S[r]=0);if("each"===p)for(a=1;a<E;++a){for(b=0,r=a;r<_;r+=E)b<A[r]&&(b=A[r]);for(r=a;r<_;r+=E)A[r]=b+z[a-1]}else if("all"===p){for(b=0,r=0;r<_;++r)r%E&&b<A[r]&&(b=A[r]);for(r=0;r<_;++r)r%E&&(A[r]=b+q)}else for(p=!1,a=1;a<E;++a)for(r=a;r<_;r+=E)A[r]+=z[a-1];if("each"===w)for(i=1;i<T;++i){for(b=0,o=(r=i*E)+E;r<o;++r)b<S[r]&&(b=S[r]);for(r=i*E;r<o;++r)S[r]=b+L[i-1]}else if("all"===w){for(b=0,r=E;r<_;++r)b<S[r]&&(b=S[r]);for(r=E;r<_;++r)S[r]=b+I}else for(w=!1,i=1;i<T;++i)for(o=(r=i*E)+E;r<o;++r)S[r]+=L[i-1];for(f=0,r=0;r<_;++r)f=A[r]+(r%E?f:0),P[r]+=f-t[r].x;for(a=0;a<E;++a)for(m=0,r=a;r<_;r+=E)m+=S[r],C[r]+=m-t[r].y;if(p&&O(n.center,"column")&&T>1)for(r=0;r<_;++r)(f=(c="all"===p?q:z[r%E])-F[r].x2-t[r].x-P[r])>0&&(P[r]+=f/2);if(w&&O(n.center,u)&&1!==E)for(r=0;r<_;++r)(m=(c="all"===w?I:L[~~(r/E)])-F[r].y2-t[r].y-C[r])>0&&(C[r]+=m/2);for(r=0;r<_;++r)g.union(F[r].translate(P[r],C[r]));switch(f=O(n.anchor,"x"),m=O(n.anchor,"y"),O(n.anchor,"column")){case s:f-=g.width();break;case"middle":f-=g.width()/2}switch(O(n.anchor,u)){case s:m-=g.height();break;case"middle":m-=g.height()/2}for(f=Math.round(f),m=Math.round(m),g.clear(),r=0;r<_;++r)t[r].mark.bounds.clear();for(r=0;r<_;++r)(l=t[r]).x+=P[r]+=f,l.y+=C[r]+=m,g.union(l.mark.bounds.union(l.bounds.translate(P[r],C[r]))),y&&e.dirty(l);return g}function S(e,t){return"x1"===t?e.x||0:"y1"===t?e.y||0:"x2"===t?(e.x||0)+(e.width||0):"y2"===t?(e.y||0)+(e.height||0):void 0}function L(e,t){return e.bounds[t]}function I(e,t,n,o,r,a,i,s,u,c,l,d,h,f){var m,b,y,x,g,p,w,k,v,M=n.length,E=0,T=0;if(!M)return E;for(m=l;m<M;m+=d)n[m]&&(E=i(E,u(n[m],c)));if(!t.length)return E;for(t.length>r&&(e.warn("Grid headers exceed limit: "+r),t=t.slice(0,r)),E+=a,b=0,x=t.length;b<x;++b)e.dirty(t[b]),t[b].mark.bounds.clear();for(m=l,b=0,x=t.length;b<x;++b,m+=d){for(g=(p=t[b]).mark.bounds,y=m;y>=0&&null==(w=n[y]);y-=h);s?(k=null==f?w.x:Math.round(w.bounds.x1+f*w.bounds.width()),v=E):(k=E,v=null==f?w.y:Math.round(w.bounds.y1+f*w.bounds.height())),g.union(p.bounds.translate(k-(p.x||0),v-(p.y||0))),p.x=k,p.y=v,e.dirty(p),T=i(T,g[c])}return T}function P(e,t,n,o,r,a){if(t){e.dirty(t);var i=n,s=n;o?i=Math.round(r.x1+a*r.width()):s=Math.round(r.y1+a*r.height()),t.bounds.translate(i-(t.x||0),s-(t.y||0)),t.mark.bounds.clear().union(t.bounds),t.x=i,t.y=s,e.dirty(t)}}function C(e,t,n,o,u,c,l){const d=function(e,t){const n=e[t]||{};return(t,o)=>null!=n[t]?n[t]:null!=e[t]?e[t]:o}(n,t),h=function(e,t){var n=-1/0;return e.forEach(e=>{null!=e.offset&&(n=Math.max(n,e.offset))}),n>-1/0?n:t}(e,d("offset",0)),f=d("anchor","start"),m=f===s?1:"middle"===f?.5:0,b={align:"each",bounds:d("bounds","flush"),columns:"vertical"===d("direction")?1:e.length,padding:d("margin",8),center:d("center"),nodirty:!0};switch(t){case a:b.anchor={x:Math.floor(o.x1)-h,column:s,y:m*(l||o.height()+2*o.y1),row:f};break;case i:b.anchor={x:Math.ceil(o.x2)+h,y:m*(l||o.height()+2*o.y1),row:f};break;case r:b.anchor={y:Math.floor(u.y1)-h,row:s,x:m*(c||u.width()+2*u.x1),column:f};break;case"bottom":b.anchor={y:Math.ceil(u.y2)+h,x:m*(c||u.width()+2*u.x1),column:f};break;case"top-left":b.anchor={x:h,y:h};break;case"top-right":b.anchor={x:c-h,y:h,column:s};break;case"bottom-left":b.anchor={x:h,y:l-h,row:s};break;case"bottom-right":b.anchor={x:c-h,y:l-h,column:s,row:s}}return b}function F(e,t){var o,r,u,c,l=t.items[0],d=l.datum,h=l.orient,f=l.bounds,m=l.x,b=l.y;return l._bounds?l._bounds.clear().union(f):l._bounds=f.clone(),f.clear(),function(e,t,n){var o=t.padding,r=o-n.x,u=o-n.y;if(t.datum.title){var c=t.items[1].items[0],l=c.anchor,d=t.titlePadding||0,h=o-c.x,f=o-c.y;switch(c.orient){case a:r+=Math.ceil(c.bounds.width())+d;break;case i:case"bottom":break;default:u+=c.bounds.height()+d}switch((r||u)&&H(e,n,r,u),c.orient){case a:f+=G(t,n,c,l,1,1);break;case i:h+=G(t,n,c,s,0,0)+d,f+=G(t,n,c,l,1,1);break;case"bottom":h+=G(t,n,c,l,0,0),f+=G(t,n,c,s,-1,0,1)+d;break;default:h+=G(t,n,c,l,0,0)}(h||f)&&H(e,c,h,f),(h=Math.round(c.bounds.x1-o))<0&&(H(e,n,-h,0),H(e,c,-h,0))}else(r||u)&&H(e,n,r,u)}(e,l,l.items[0].items[0]),f=function(e,t){return e.items.forEach(e=>t.union(e.bounds)),t.x1=e.padding,t.y1=e.padding,t}(l,f),o=2*l.padding,r=2*l.padding,f.empty()||(o=Math.ceil(f.width()+o),r=Math.ceil(f.height()+r)),"symbol"===d.type&&(u=l.items[0].items[0].items[0].items,c=u.reduce((e,t)=>(e[t.column]=Math.max(t.bounds.x2-t.x,e[t.column]||0),e),{}),u.forEach(e=>{e.width=c[e.column],e.height=e.bounds.y2-e.y})),"none"!==h&&(l.x=m=0,l.y=b=0),l.width=o,l.height=r,n.boundStroke(f.set(m,b,m+o,b+r),l),l.mark.bounds.clear().union(f),l}function G(e,t,o,r,a,i,u){const c="symbol"!==e.datum.type,l=o.datum.vgrad,d=(!c||!i&&l||u?t:t.items[0]).bounds[a?"y2":"x2"]-e.padding,h=l&&i?d:0,f=l&&i?0:d,m=a<=0?0:n.multiLineOffset(o);return Math.round("start"===r?h:r===s?f-m:.5*(d-m))}function H(e,t,n,o){t.x+=n,t.y+=o,t.bounds.translate(n,o),t.mark.bounds.translate(n,o),e.dirty(t)}function R(e){t.Transform.call(this,null,e)}o.inherits(R,t.Transform).transform=function(e,t){var o,c=t.dataflow;return e.mark.items.forEach(t=>{e.layout&&function(e,t,n){var o,r,a,i,c,l,d,h=function(e){for(var t,n,o=e.items,r=o.length,a=0,i={marks:[],rowheaders:[],rowfooters:[],colheaders:[],colfooters:[],rowtitle:null,coltitle:null};a<r;++a)if(n=(t=o[a]).items,"group"===t.marktype)switch(t.role){case"axis":case"legend":case"title":break;case"row-header":i.rowheaders.push(...n);break;case"row-footer":i.rowfooters.push(...n);break;case"column-header":i.colheaders.push(...n);break;case"column-footer":i.colfooters.push(...n);break;case"row-title":i.rowtitle=n[0];break;case"column-title":i.coltitle=n[0];break;default:i.marks.push(...n)}return i}(t),f=h.marks,m="flush"===n.bounds?S:L,b=n.offset,y=n.columns||f.length,x=y<=0?1:Math.ceil(f.length/y),g=x*y;const p=q(e,f,n);p.empty()&&p.set(0,0,0,0),h.rowheaders&&(l=O(n.headerBand,u,null),o=I(e,h.rowheaders,f,y,x,-O(b,"rowHeader"),A,0,m,"x1",0,y,1,l)),h.colheaders&&(l=O(n.headerBand,"column",null),r=I(e,h.colheaders,f,y,y,-O(b,"columnHeader"),A,1,m,"y1",0,1,y,l)),h.rowfooters&&(l=O(n.footerBand,u,null),a=I(e,h.rowfooters,f,y,x,O(b,"rowFooter"),z,0,m,"x2",y-1,y,1,l)),h.colfooters&&(l=O(n.footerBand,"column",null),i=I(e,h.colfooters,f,y,y,O(b,"columnFooter"),z,1,m,"y2",g-y,1,y,l)),h.rowtitle&&(c=O(n.titleAnchor,u),d=O(b,"rowTitle"),d=c===s?a+d:o-d,l=O(n.titleBand,u,.5),P(e,h.rowtitle,d,0,p,l)),h.coltitle&&(c=O(n.titleAnchor,"column"),d=O(b,"columnTitle"),d=c===s?i+d:r-d,l=O(n.titleBand,"column",.5),P(e,h.coltitle,d,1,p,l))}(c,t,e.layout),function(e,t,o){var u,c,l,d,h,f=t.items,m=Math.max(0,t.width||0),b=Math.max(0,t.height||0),y=(new n.Bounds).set(0,0,m,b),x=y.clone(),g=y.clone(),p=[];for(d=0,h=f.length;d<h;++d)switch((c=f[d]).role){case"axis":(E(c)?x:g).union(T(e,c,m,b));break;case"title":u=c;break;case"legend":p.push(F(e,c));break;case"frame":case"scope":case"row-header":case"row-footer":case"row-title":case"column-header":case"column-footer":case"column-title":x.union(c.bounds),g.union(c.bounds);break;default:y.union(c.bounds)}if(p.length){const t={};p.forEach(e=>{"none"!==(l=e.orient||i)&&(t[l]||(t[l]=[])).push(e)});for(let n in t){const r=t[n];q(e,r,C(r,n,o.legends,x,g,m,b))}p.forEach(t=>{const n=t.bounds;if(n.equals(t._bounds)||(t.bounds=t._bounds,e.dirty(t),t.bounds=n,e.dirty(t)),o.autosize&&"fit"===o.autosize.type)switch(t.orient){case a:case i:y.add(n.x1,0).add(n.x2,0);break;case r:case"bottom":y.add(0,n.y1).add(0,n.y2)}else y.union(n)})}y.union(x).union(g),u&&y.union(function(e,t,n,o,u){var c,l=t.items[0],d=l.frame,h=l.orient,f=l.anchor,m=l.offset,b=l.padding,y=l.items[0].items[0],x=l.items[1]&&l.items[1].items[0],g=h===a||h===i?o:n,p=0,w=0,k=0,E=0,T=0;if("group"!==d?h===a?(p=u.y2,g=u.y1):h===i?(p=u.y1,g=u.y2):(p=u.x1,g=u.x2):h===a&&(p=o,g=0),c="start"===f?p:f===s?g:(p+g)/2,x&&x.text){switch(h){case r:case"bottom":T=y.bounds.height()+b;break;case a:E=y.bounds.width()+b;break;case i:E=-y.bounds.width()-b}v.clear().union(x.bounds),v.translate(E-(x.x||0),T-(x.y||0)),M(x,"x",E)|M(x,"y",T)&&(e.dirty(x),x.bounds.clear().union(v),x.mark.bounds.clear().union(v),e.dirty(x)),v.clear().union(x.bounds)}else v.clear();switch(v.union(y.bounds),h){case r:w=c,k=u.y1-v.height()-m;break;case a:w=u.x1-v.width()-m,k=c;break;case i:w=u.x2+v.width()+m,k=c;break;case"bottom":w=c,k=u.y2+m;break;default:w=l.x,k=l.y}return M(l,"x",w)|M(l,"y",k)&&(v.translate(w,k),e.dirty(l),l.bounds.clear().union(v),t.bounds.clear().union(v),e.dirty(l)),l.bounds}(e,u,m,b,y));t.clip&&y.set(0,0,t.width||0,t.height||0);!function(e,t,n,o){const r=o.autosize||{},a=r.type;if(e._autosize<1||!a)return;let i=e._width,s=e._height,u=Math.max(0,t.width||0),c=Math.max(0,Math.ceil(-n.x1)),l=Math.max(0,Math.ceil(n.x2-u)),d=Math.max(0,t.height||0),h=Math.max(0,Math.ceil(-n.y1)),f=Math.max(0,Math.ceil(n.y2-d));if("padding"===r.contains){const t=e.padding();i-=t.left+t.right,s-=t.top+t.bottom}"none"===a?(c=0,h=0,u=i,d=s):"fit"===a?(u=Math.max(0,i-c-l),d=Math.max(0,s-h-f)):"fit-x"===a?(u=Math.max(0,i-c-l),s=d+h+f):"fit-y"===a?(i=u+c+l,d=Math.max(0,s-h-f)):"pad"===a&&(i=u+c+l,s=d+h+f);e._resizeView(i,s,u,d,[c,h],r.resize)}(e,t,y,o)}(c,t,e)}),(o=e.mark.group)&&"legend-entry"!==o.mark.role?t.reflow():t},e.bound=c,e.identifier=d,e.mark=h,e.overlap=f,e.render=k,e.viewlayout=R,Object.defineProperty(e,"__esModule",{value:!0})}));