Socket
Socket
Sign inDemoInstall

vega-view-transforms

Package Overview
Dependencies
30
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.5.1 to 4.5.2

9

build/vega-view-transforms.js

@@ -344,2 +344,8 @@ (function (global, factory) {

// skip labels with no content
source = source.filter(hasBounds);
// early exit, nothing to do
if (!source.length) return;
if (_.sort) {

@@ -349,5 +355,2 @@ source = source.slice().sort(_.sort);

// skip labels with no content
source = source.filter(hasBounds);
items = reset(source);

@@ -354,0 +357,0 @@ pulse = reflow(pulse, _);

@@ -1,1 +0,1 @@

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

@@ -26,4 +26,4 @@ "keywords": [

"dependencies": {
"vega-dataflow": "^5.4.1",
"vega-scenegraph": "^4.4.0",
"vega-dataflow": "^5.5.0",
"vega-scenegraph": "^4.6.0",
"vega-util": "^1.13.1"

@@ -34,3 +34,3 @@ },

},
"gitHead": "2bee653f2a56c2c0d4393d69d172b9ccdb0fe2f9"
"gitHead": "2485e6f68a1cec25260c8c07b812f24925c5d726"
}

@@ -117,2 +117,8 @@ import {Top, Bottom} from './constants';

// skip labels with no content
source = source.filter(hasBounds);
// early exit, nothing to do
if (!source.length) return;
if (_.sort) {

@@ -122,5 +128,2 @@ source = source.slice().sort(_.sort);

// skip labels with no content
source = source.filter(hasBounds);
items = reset(source);

@@ -127,0 +130,0 @@ pulse = reflow(pulse, _);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc