Socket
Socket
Sign inDemoInstall

vega-view-transforms

Package Overview
Dependencies
3
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.1 to 4.1.0

106

build/vega-view-transforms.js

@@ -1010,3 +1010,3 @@ (function (global, factory) {

bounds.translate(x - item.x, y - item.y);
bounds.translate(x - (item.x || 0), y - (item.y || 0));
if (set(item, 'x', x) | set(item, 'y', y)) {

@@ -1025,3 +1025,3 @@ item.bounds = tempBounds;

return legends.reduce(function(w, legend) {
var item = legend.items[0];
const item = legend.items[0];

@@ -1031,6 +1031,6 @@ // adjust entry to accommodate padding and title

// if left-oriented, calculate maximum legend width
if (item.datum.orient === Left) {
var b = tempBounds.clear();
item.items.forEach(function(_) { b.union(_.bounds); });
w = Math.max(w, Math.ceil(b.width() + 2 * item.padding - 1));
const b = legendBounds(item, tempBounds.clear());
w = Math.max(w, Math.ceil(b.width() + 2 * item.padding));
}

@@ -1042,20 +1042,83 @@

function legendBounds(item, b) {
// aggregate item bounds
item.items.forEach(_ => b.union(_.bounds));
// anchor to legend origin
b.x1 = item.padding;
b.y1 = item.padding;
return b;
}
function legendGroupLayout(view, item, entry) {
var x = item.padding - entry.x,
y = item.padding - entry.y;
var pad = item.padding,
ex = pad - entry.x,
ey = pad - entry.y;
if (item.datum.title) {
var title = item.items[1].items[0];
y += item.titlePadding + title.fontSize;
}
if (!item.datum.title) {
if (ex || ey) translate(view, entry, ex, ey);
} else {
var title = item.items[1].items[0],
anchor = title.anchor,
tpad = item.titlePadding || 0,
tx = pad - title.x,
ty = pad - title.y;
if (x || y) {
entry.x += x;
entry.y += y;
entry.bounds.translate(x, y);
entry.mark.bounds.translate(x, y);
view.dirty(entry);
switch (title.orient) {
case Left:
ex += Math.ceil(title.bounds.width()) + tpad;
break;
case Right:
case Bottom:
break;
default:
ey += title.fontSize + tpad;
}
if (ex || ey) translate(view, entry, ex, ey);
switch (title.orient) {
case Left:
ty += legendTitleOffset(item, entry, title, anchor, 0, 1);
break;
case Right:
tx += legendTitleOffset(item, entry, title, End, 1, 0) + tpad;
ty += legendTitleOffset(item, entry, title, anchor, 0, 1);
break;
case Bottom:
tx += legendTitleOffset(item, entry, title, anchor, 1, 0);
ty += legendTitleOffset(item, entry, title, End, 0, 0, 1) + tpad;
break;
default:
tx += legendTitleOffset(item, entry, title, anchor, 1, 0);
}
if (tx || ty) translate(view, title, tx, ty);
// translate legend if title pushes into negative coordinates
if ((tx = Math.round(title.bounds.x1 - pad)) < 0) {
translate(view, entry, -tx, 0);
translate(view, title, -tx, 0);
}
}
}
function legendTitleOffset(item, entry, title, anchor, x, lr, noBar) {
const grad = item.datum.type !== 'symbol',
vgrad = title.datum.vgrad,
e = grad && (lr || !vgrad) && !noBar ? entry.items[0] : entry,
s = e.bounds[x ? 'x2' : 'y2'] - item.padding,
u = vgrad && lr ? s : 0,
v = vgrad && lr ? 0 : s;
return ~~(anchor === Start ? u : anchor === End ? v : 0.5 * s);
}
function translate(view, item, dx, dy) {
item.x += dx;
item.y += dy;
item.bounds.translate(dx, dy);
item.mark.bounds.translate(dx, dy);
view.dirty(item);
}
function legendLayout(view, legend, flow, xBounds, yBounds, width, height) {

@@ -1082,7 +1145,6 @@ var item = legend.items[0],

// aggregate bounds to determine size
// shave off 1 pixel because it looks better...
item.items.forEach(function(_) { bounds.union(_.bounds); });
w = 2 * item.padding - 1;
h = 2 * item.padding - 1;
// aggregate bounds to determine size, and include origin
bounds = legendBounds(item, bounds);
w = 2 * item.padding;
h = 2 * item.padding;
if (!bounds.empty()) {

@@ -1089,0 +1151,0 @@ w = Math.ceil(bounds.width() + w);

@@ -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,r){"use strict";var a="top",o="left",i="right",u="bottom",s="top-left",d="top-right",l="bottom-left",c="bottom-right",f="start",h="end",m="group",b="axis",y="title",x="frame",g="scope",p="legend",v="row-header",k="row-footer",M="row-title",w="column-header",T="column-footer",E="column-title",z="padding",B="symbol",D="fit",_="fit-x",O="fit-y",S="pad",j="none",q="all",A="each",I="flush",P="column",W="row";function C(t){e.Transform.call(this,null,t)}function F(t,e,n){return e(t.bounds.clear(),t,n)}r.inherits(C,e.Transform).transform=function(t,e){var r,a=e.dataflow,o=t.mark,i=o.marktype,u=n.Marks[i],s=u.bound,d=o.bounds;return u.nested?(o.items.length&&a.dirty(o.items[0]),d=F(o,s),o.items.forEach(function(t){t.bounds.clear().union(d)})):i===m||t.modified()?(e.visit(e.MOD,function(t){a.dirty(t)}),d.clear(),o.items.forEach(function(t){d.union(F(t,s))}),o.role===p&&e.reflow()):(r=e.changed(e.REM),e.visit(e.ADD,function(t){d.union(F(t,s))}),e.visit(e.MOD,function(t){r=r||d.alignsWith(t.bounds),a.dirty(t),d.union(F(t,s))}),r&&(d.clear(),o.items.forEach(function(t){d.union(t.bounds)}))),n.boundClip(o),e.modifies("bounds")};var G=":vega_identifier:";function H(t){e.Transform.call(this,0,t)}function L(t){e.Transform.call(this,null,t)}function R(t){e.Transform.call(this,null,t)}H.Definition={type:"Identifier",metadata:{modifies:!0},params:[{name:"as",type:"string",required:!0}]},r.inherits(H,e.Transform).transform=function(t,e){var n=function(t){var e=t._signals[G];e||(t._signals[G]=e=t.add(0));return e}(e.dataflow),r=n.value,a=t.as;return e.visit(e.ADD,function(t){t[a]||(t[a]=++r)}),n.set(this.value=r),e},r.inherits(L,e.Transform).transform=function(t,e){var r=this.value;r||((r=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=r.group),r.source=this,r.clip=t.clip,r.interactive=t.interactive,this.value=r);var a=r.marktype===m?n.GroupItem:n.Item;return e.visit(e.ADD,function(t){a.call(t,r)}),(t.modified("clip")||t.modified("interactive"))&&(r.clip=t.clip,r.interactive=!!t.interactive,r.zdirty=!0,e.reflow()),r.items=e.source,e};var U=r.inherits(R,e.Transform),V={parity:function(t){return t.filter(function(t,e){return e%2?t.opacity=0:1})},greedy:function(t,e){var n;return t.filter(function(t,r){return r&&J(n.bounds,t.bounds,e)?t.opacity=0:(n=t,1)})}};function J(t,e,n){return n>Math.max(e.x1-t.x2,t.x1-e.x2,e.y1-t.y2,t.y1-e.y2)}function K(t,e){for(var n,r=1,a=t.length,o=t[0].bounds;r<a;o=n,++r)if(J(o,n=t[r].bounds,e))return!0}function N(t){var e=t.bounds;return e.width()>1&&e.height()>1}function Q(t){return t.forEach(function(t){t.opacity=1}),t}function X(t,e){return t.reflow(e.modified()).modifies("opacity")}function Y(t){e.Transform.call(this,null,t)}function Z(t,e){for(var n=0,r=t.length;n<r;++n)e.push(t[n])}function $(t){return{x1:0,y1:0,x2:t.width||0,y2:t.height||0}}function tt(t){var e=t.bounds.clone();return e.empty()?e.set(0,0,0,0):e.translate(-(t.x||0),-(t.y||0))}function et(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 nt(t,e){return t.bounds[e]}function rt(t,e,n){var a=r.isObject(t)?t[e]:t;return null!=a?a:void 0!==n?n:0}function at(t){return t<0?Math.ceil(-t):0}function ot(t,e,r){var a,o,i,u,s,d,l,c,f,h,y,x,g=function(t){for(var e,n,r=t.items,a=r.length,o=0,i={marks:[],rowheaders:[],rowfooters:[],colheaders:[],colfooters:[],rowtitle:null,coltitle:null};o<a;++o)if(n=(e=r[o]).items,e.marktype===m)switch(e.role){case b:case p:break;case v:Z(n,i.rowheaders);break;case k:Z(n,i.rowfooters);break;case w:Z(n,i.colheaders);break;case T:Z(n,i.colfooters);break;case M:i.rowtitle=n[0];break;case E:i.coltitle=n[0];break;default:Z(n,i.marks)}return i}(e),z=g.marks,B=r.bounds===I,D=B?$:tt,_=new n.Bounds(0,0,0,0),O=rt(r.align,P),S=rt(r.align,W),j=rt(r.padding,P),C=rt(r.padding,W),F=r.offset,G=e.columns||r.columns||z.length,H=G<0?1:Math.ceil(z.length/G),L=H*G,R=[],U=[],V=0,J=[],K=[],N=0,Q=z.length;for(o=0;o<G;++o)U[o]=0;for(o=0;o<H;++o)K[o]=0;for(o=0;o<Q;++o)s=D(z[o]),i=o%G,u=~~(o/G),l=Math.ceil(D(z[o]).x2),c=Math.ceil(D(z[o]).y2),V=Math.max(V,l),N=Math.max(N,c),U[i]=Math.max(U[i],l),K[u]=Math.max(K[u],c),R.push(j+at(s.x1)),J.push(C+at(s.y1)),t.dirty(z[o]);for(o=0;o<Q;++o)o%G==0&&(R[o]=0),o<G&&(J[o]=0);if(O===A)for(i=1;i<G;++i){for(x=0,o=i;o<Q;o+=G)x<R[o]&&(x=R[o]);for(o=i;o<Q;o+=G)R[o]=x+U[i-1]}else if(O===q){for(x=0,o=0;o<Q;++o)o%G&&x<R[o]&&(x=R[o]);for(o=0;o<Q;++o)o%G&&(R[o]=x+V)}else for(O=!1,i=1;i<G;++i)for(o=i;o<Q;o+=G)R[o]+=U[i-1];if(S===A)for(u=1;u<H;++u){for(x=0,a=(o=u*G)+G;o<a;++o)x<J[o]&&(x=J[o]);for(o=u*G;o<a;++o)J[o]=x+K[u-1]}else if(S===q){for(x=0,o=G;o<Q;++o)x<J[o]&&(x=J[o]);for(o=G;o<Q;++o)J[o]=x+N}else for(S=!1,u=1;u<H;++u)for(a=(o=u*G)+G;o<a;++o)J[o]+=K[u-1];for(f=0,o=0;o<Q;++o)l=(d=z[o]).x||0,d.x=f=R[o]+(o%G?f:0),d.bounds.translate(f-l,0);for(i=0;i<G;++i)for(h=0,o=i;o<Q;o+=G)c=(d=z[o]).y||0,d.y=h+=J[o],d.bounds.translate(0,h-c);if(rt(r.center,P)&&H>1&&O)for(o=0;o<Q;++o)d=z[o],(f=(s=O===q?V:U[o%G])-D(d).x2)>0&&(d.x+=l=f/2,d.bounds.translate(l,0));if(rt(r.center,W)&&1!==G&&S)for(o=0;o<Q;++o)d=z[o],(h=(s=S===q?N:K[~~(o/G)])-D(d).y2)>0&&(d.y+=c=h/2,d.bounds.translate(0,c));for(o=0;o<Q;++o)z[o].mark.bounds.clear();for(o=0;o<Q;++o)d=z[o],t.dirty(d),_.union(d.mark.bounds.union(d.bounds));function X(t,e){return Math.floor(Math.min(t,e))}function Y(t,e){return Math.ceil(Math.max(t,e))}D=B?et:nt,y=rt(r.headerBand,W,null),f=it(t,g.rowheaders,z,G,H,-rt(F,"rowHeader"),X,0,D,"x1",0,G,1,y),y=rt(r.headerBand,P,null),h=it(t,g.colheaders,z,G,G,-rt(F,"columnHeader"),X,1,D,"y1",0,1,G,y),y=rt(r.footerBand,W,null),it(t,g.rowfooters,z,G,H,rt(F,"rowFooter"),Y,0,D,"x2",G-1,G,1,y),y=rt(r.footerBand,P,null),it(t,g.colfooters,z,G,G,rt(F,"columnFooter"),Y,1,D,"y2",L-G,1,G,y),g.rowtitle&&(x=f-rt(F,"rowTitle"),y=rt(r.titleBand,W,.5),ut(t,g.rowtitle,x,0,_,y)),g.coltitle&&(x=h-rt(F,"columnTitle"),y=rt(r.titleBand,P,.5),ut(t,g.coltitle,x,1,_,y))}function it(t,e,n,r,a,o,i,u,s,d,l,c,f,h){var m,b,y,x,g,p,v,k,M,w=n.length,T=0,E=0;if(!w)return T;for(m=l;m<w;m+=c)n[m]&&(T=i(T,s(n[m],d)));if(!e.length)return T;for(e.length>a&&(t.warn("Grid headers exceed limit: "+a),e=e.slice(0,a)),T+=o,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+=c){for(g=(p=e[b]).mark.bounds,y=m;y>=0&&null==(v=n[y]);y-=f);u?(k=null==h?v.x:Math.round(v.bounds.x1+h*v.bounds.width()),M=T):(k=T,M=null==h?v.y:Math.round(v.bounds.y1+h*v.bounds.height())),g.union(p.bounds.translate(k-(p.x||0),M-(p.y||0))),p.x=k,p.y=M,t.dirty(p),E=i(E,g[d])}return E}function ut(t,e,n,r,a,o){if(e){t.dirty(e);var i=n,u=n;r?i=Math.round(a.x1+o*a.width()):u=Math.round(a.y1+o*a.height()),e.bounds.translate(i-(e.x||0),u-(e.y||0)),e.mark.bounds.clear().union(e.bounds),e.x=i,e.y=u,t.dirty(e)}}U.transform=function(t,e){var o,i,s=V[t.method]||V.parity,d=e.materialize(e.SOURCE).source,l=t.separation||0;if(d){if(!t.method)return t.modified("method")&&(Q(d),e=X(e,t)),e;if(t.sort&&(d=d.slice().sort(t.sort)),o=Q(d=d.filter(N)),e=X(e,t),o.length>=3&&K(o,l)){do{o=s(o,l)}while(o.length>=3&&K(o,l));o.length<3&&!r.peek(d).opacity&&(o.length>1&&(r.peek(o).opacity=0),r.peek(d).opacity=1)}var c,f,h,m,b;return t.boundScale&&t.boundTolerance>=0&&(c=t.boundScale,f=t.boundOrient,h=+t.boundTolerance,m=c.range(),b=new n.Bounds,f===a||f===u?b.set(m[0],-1/0,m[1],1/0):b.set(-1/0,m[0],1/0,m[1]),b.expand(h||1),i=function(t){return b.encloses(t.bounds)},d.forEach(function(t){i(t)||(t.opacity=0)})),e}},r.inherits(Y,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 r=e.source&&e.source[0];r&&(r.mark.zdirty=!0)}};var st=.5,dt=new n.Bounds;function lt(t){e.Transform.call(this,null,t)}function ct(t,e,n){return t[e]===n?0:(t[e]=n,1)}function ft(t){var e=t.items[0].datum.orient;return e===o||e===i}function ht(t,e,r,s){var d,l,c=e.items[0],f=c.datum,h=f.orient,m=function(t){var e=+t.grid;return[t.ticks?e++:-1,t.labels?e++:-1,e+ +t.domain]}(f),b=c.range,y=c.offset,x=c.position,g=c.minExtent,p=c.maxExtent,v=f.title&&c.items[m[2]].items[0],k=c.titlePadding,M=c.bounds,w=0,T=0;switch(dt.clear().union(M),M.clear(),(d=m[0])>-1&&M.union(c.items[d].bounds),(d=m[1])>-1&&M.union(c.items[d].bounds),h){case a:w=x||0,T=-y,l=Math.max(g,Math.min(p,-M.y1)),v&&(l=mt(v,l,k,0,-1,M)),M.add(0,-l).add(b,0);break;case o:w=-y,T=x||0,l=Math.max(g,Math.min(p,-M.x1)),v&&(l=mt(v,l,k,1,-1,M)),M.add(-l,0).add(0,b);break;case i:w=r+y,T=x||0,l=Math.max(g,Math.min(p,M.x2)),v&&(l=mt(v,l,k,1,1,M)),M.add(0,0).add(l,b);break;case u:w=x||0,T=s+y,l=Math.max(g,Math.min(p,M.y2)),v&&(l=mt(v,l,k,0,1,M)),M.add(0,0).add(b,l);break;default:w=c.x,T=c.y}return n.boundStroke(M.translate(w,T),c),ct(c,"x",w+st)|ct(c,"y",T+st)&&(c.bounds=dt,t.dirty(c),c.bounds=M,t.dirty(c)),c.mark.bounds.clear().union(M)}function mt(t,e,n,r,a,o){var i=t.bounds,u=0,s=0;return t.auto?(e+=n,r?u=(t.x||0)-(t.x=a*e):s=(t.y||0)-(t.y=a*e),i.translate(-u,-s),t.mark.bounds.set(i.x1,i.y1,i.x2,i.y2),r?(o.add(0,i.y1).add(0,i.y2),e+=i.width()):(o.add(i.x1,0).add(i.x2,0),e+=i.height())):o.union(i),e}function bt(t,e){return e.reduce(function(e,n){var r=n.items[0];if(function(t,e,n){var r=e.padding-n.x,a=e.padding-n.y;if(e.datum.title){var o=e.items[1].items[0];a+=e.titlePadding+o.fontSize}(r||a)&&(n.x+=r,n.y+=a,n.bounds.translate(r,a),n.mark.bounds.translate(r,a),t.dirty(n))}(t,r,r.items[0].items[0]),r.datum.orient===o){var a=dt.clear();r.items.forEach(function(t){a.union(t.bounds)}),e=Math.max(e,Math.ceil(a.width()+2*r.padding-1))}return e},0)}function yt(t,e,r,f,h,m,b){var y,x,g,p,v,k=e.items[0],M=k.datum,w=M.orient,T=k.offset,E=k.bounds,z=0,D=0;switch(w===a||w===u?(g=h,z=r[w]):w!==o&&w!==i||(g=f,D=r[w]),dt.clear().union(E),E.clear(),k.items.forEach(function(t){E.union(t.bounds)}),y=2*k.padding-1,x=2*k.padding-1,E.empty()||(y=Math.ceil(E.width()+y),x=Math.ceil(E.height()+x)),M.type===B&&(p=k.items[0].items[0].items[0].items,v=p.reduce(function(t,e){return t[e.column]=Math.max(e.bounds.x2-e.x,t[e.column]||0),t},{}),p.forEach(function(t){t.width=v[t.column],t.height=t.bounds.y2-t.y})),w){case o:z-=r.leftWidth+T-Math.floor(g.x1),r.left+=x+r.margin;break;case i:z+=T+Math.ceil(g.x2),r.right+=x+r.margin;break;case a:D-=x+T-Math.floor(g.y1),r.top+=y+r.margin;break;case u:D+=T+Math.ceil(g.y2),r.bottom+=y+r.margin;break;case s:z+=T,D+=T;break;case d:z+=m-y-T,D+=T;break;case l:z+=T,D+=b-x-T;break;case c:z+=m-y-T,D+=b-x-T;break;default:z=k.x,D=k.y}return n.boundStroke(E.set(z,D,z+y,D+x),k),ct(k,"x",z)|ct(k,"width",y)|ct(k,"y",D)|ct(k,"height",x)&&(k.bounds=dt,t.dirty(k),k.bounds=E,t.dirty(k)),k.mark.bounds.clear().union(E)}r.inherits(lt,e.Transform).transform=function(t,e){var r=e.dataflow;return t.mark.items.forEach(function(e){t.layout&&ot(r,e,t.layout),function(t,e,r){var s,d,l,c,B,q,A=e.items,I=Math.max(0,e.width||0),P=Math.max(0,e.height||0),W=(new n.Bounds).set(0,0,I,P),C=W.clone(),F=W.clone(),G=[];for(B=0,q=A.length;B<q;++B)switch((d=A[B]).role){case b:(c=ft(d)?C:F).union(ht(t,d,I,P));break;case y:s=d;break;case p:G.push(d);break;case x:case g:case v:case k:case M:case w:case T:case E:C.union(d.bounds),F.union(d.bounds);break;default:W.union(d.bounds)}if(G.length)for(l={leftWidth:bt(t,G),margin:r.legendMargin||8,left:0,right:0,top:0,bottom:0},B=0,q=G.length;B<q;++B)if(c=yt(t,G[B],l,C,F,I,P),r.autosize&&r.autosize.type===D){var H=G[B].items[0].datum.orient;H===o||H===i?W.add(c.x1,0).add(c.x2,0):H!==a&&H!==u||W.add(0,c.y1).add(0,c.y2)}else W.union(c);W.union(C).union(F),s&&W.union(function(t,e,n,r,s){var d,l=e.items[0],c=l.orient,b=l.frame,y=l.anchor,x=l.offset,g=l.bounds,p=0,v=c===o||c===i?r:n,k=0,M=0;b!==m?c===o?(p=s.y2,v=s.y1):c===i?(p=s.y1,v=s.y2):(p=s.x1,v=s.x2):c===o&&(p=r,v=0);switch(d=y===f?p:y===h?v:(p+v)/2,dt.clear().union(g),c){case a:k=d,M=s.y1-x;break;case o:k=s.x1-x,M=d;break;case i:k=s.x2+x,M=d;break;case u:k=d,M=s.y2+x;break;default:k=l.x,M=l.y}g.translate(k-l.x,M-l.y),ct(l,"x",k)|ct(l,"y",M)&&(l.bounds=dt,t.dirty(l),l.bounds=g,t.dirty(l));return e.bounds.clear().union(g)}(t,s,I,P,W));!function(t,e,n,r){var a=r.autosize||{},o=a.type,i=t._width,u=t._height,s=t.padding();if(t._autosize<1||!o)return;var d=Math.max(0,e.width||0),l=Math.max(0,Math.ceil(-n.x1)),c=Math.max(0,Math.ceil(n.x2-d)),f=Math.max(0,e.height||0),h=Math.max(0,Math.ceil(-n.y1)),m=Math.max(0,Math.ceil(n.y2-f));a.contains===z&&(i-=s.left+s.right,u-=s.top+s.bottom);o===j?(l=0,h=0,d=i,f=u):o===D?(d=Math.max(0,i-l-c),f=Math.max(0,u-h-m)):o===_?(d=Math.max(0,i-l-c),u=f+h+m):o===O?(i=d+l+c,f=Math.max(0,u-h-m)):o===S&&(i=d+l+c,u=f+h+m);t._resizeView(i,u,d,f,[l,h],a.resize)}(t,e,W,r)}(r,e,t)}),t.modified()&&e.reflow(),e},t.bound=C,t.identifier=H,t.mark=L,t.overlap=R,t.render=Y,t.viewlayout=lt,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,r){"use strict";var a="top",o="left",i="right",u="bottom",s="top-left",d="top-right",c="bottom-left",l="bottom-right",f="start",h="end",m="group",b="axis",y="title",x="frame",g="scope",p="legend",v="row-header",k="row-footer",M="row-title",w="column-header",T="column-footer",z="column-title",E="padding",B="symbol",D="fit",_="fit-x",O="fit-y",S="pad",j="none",q="all",A="each",I="flush",P="column",W="row";function C(t){e.Transform.call(this,null,t)}function F(t,e,n){return e(t.bounds.clear(),t,n)}r.inherits(C,e.Transform).transform=function(t,e){var r,a=e.dataflow,o=t.mark,i=o.marktype,u=n.Marks[i],s=u.bound,d=o.bounds;return u.nested?(o.items.length&&a.dirty(o.items[0]),d=F(o,s),o.items.forEach(function(t){t.bounds.clear().union(d)})):i===m||t.modified()?(e.visit(e.MOD,function(t){a.dirty(t)}),d.clear(),o.items.forEach(function(t){d.union(F(t,s))}),o.role===p&&e.reflow()):(r=e.changed(e.REM),e.visit(e.ADD,function(t){d.union(F(t,s))}),e.visit(e.MOD,function(t){r=r||d.alignsWith(t.bounds),a.dirty(t),d.union(F(t,s))}),r&&(d.clear(),o.items.forEach(function(t){d.union(t.bounds)}))),n.boundClip(o),e.modifies("bounds")};var G=":vega_identifier:";function H(t){e.Transform.call(this,0,t)}function L(t){e.Transform.call(this,null,t)}function R(t){e.Transform.call(this,null,t)}H.Definition={type:"Identifier",metadata:{modifies:!0},params:[{name:"as",type:"string",required:!0}]},r.inherits(H,e.Transform).transform=function(t,e){var n=function(t){var e=t._signals[G];e||(t._signals[G]=e=t.add(0));return e}(e.dataflow),r=n.value,a=t.as;return e.visit(e.ADD,function(t){t[a]||(t[a]=++r)}),n.set(this.value=r),e},r.inherits(L,e.Transform).transform=function(t,e){var r=this.value;r||((r=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=r.group),r.source=this,r.clip=t.clip,r.interactive=t.interactive,this.value=r);var a=r.marktype===m?n.GroupItem:n.Item;return e.visit(e.ADD,function(t){a.call(t,r)}),(t.modified("clip")||t.modified("interactive"))&&(r.clip=t.clip,r.interactive=!!t.interactive,r.zdirty=!0,e.reflow()),r.items=e.source,e};var U=r.inherits(R,e.Transform),V={parity:function(t){return t.filter(function(t,e){return e%2?t.opacity=0:1})},greedy:function(t,e){var n;return t.filter(function(t,r){return r&&J(n.bounds,t.bounds,e)?t.opacity=0:(n=t,1)})}};function J(t,e,n){return n>Math.max(e.x1-t.x2,t.x1-e.x2,e.y1-t.y2,t.y1-e.y2)}function K(t,e){for(var n,r=1,a=t.length,o=t[0].bounds;r<a;o=n,++r)if(J(o,n=t[r].bounds,e))return!0}function N(t){var e=t.bounds;return e.width()>1&&e.height()>1}function Q(t){return t.forEach(function(t){t.opacity=1}),t}function X(t,e){return t.reflow(e.modified()).modifies("opacity")}function Y(t){e.Transform.call(this,null,t)}function Z(t,e){for(var n=0,r=t.length;n<r;++n)e.push(t[n])}function $(t){return{x1:0,y1:0,x2:t.width||0,y2:t.height||0}}function tt(t){var e=t.bounds.clone();return e.empty()?e.set(0,0,0,0):e.translate(-(t.x||0),-(t.y||0))}function et(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 nt(t,e){return t.bounds[e]}function rt(t,e,n){var a=r.isObject(t)?t[e]:t;return null!=a?a:void 0!==n?n:0}function at(t){return t<0?Math.ceil(-t):0}function ot(t,e,r){var a,o,i,u,s,d,c,l,f,h,y,x,g=function(t){for(var e,n,r=t.items,a=r.length,o=0,i={marks:[],rowheaders:[],rowfooters:[],colheaders:[],colfooters:[],rowtitle:null,coltitle:null};o<a;++o)if(n=(e=r[o]).items,e.marktype===m)switch(e.role){case b:case p:break;case v:Z(n,i.rowheaders);break;case k:Z(n,i.rowfooters);break;case w:Z(n,i.colheaders);break;case T:Z(n,i.colfooters);break;case M:i.rowtitle=n[0];break;case z:i.coltitle=n[0];break;default:Z(n,i.marks)}return i}(e),E=g.marks,B=r.bounds===I,D=B?$:tt,_=new n.Bounds(0,0,0,0),O=rt(r.align,P),S=rt(r.align,W),j=rt(r.padding,P),C=rt(r.padding,W),F=r.offset,G=e.columns||r.columns||E.length,H=G<0?1:Math.ceil(E.length/G),L=H*G,R=[],U=[],V=0,J=[],K=[],N=0,Q=E.length;for(o=0;o<G;++o)U[o]=0;for(o=0;o<H;++o)K[o]=0;for(o=0;o<Q;++o)s=D(E[o]),i=o%G,u=~~(o/G),c=Math.ceil(D(E[o]).x2),l=Math.ceil(D(E[o]).y2),V=Math.max(V,c),N=Math.max(N,l),U[i]=Math.max(U[i],c),K[u]=Math.max(K[u],l),R.push(j+at(s.x1)),J.push(C+at(s.y1)),t.dirty(E[o]);for(o=0;o<Q;++o)o%G==0&&(R[o]=0),o<G&&(J[o]=0);if(O===A)for(i=1;i<G;++i){for(x=0,o=i;o<Q;o+=G)x<R[o]&&(x=R[o]);for(o=i;o<Q;o+=G)R[o]=x+U[i-1]}else if(O===q){for(x=0,o=0;o<Q;++o)o%G&&x<R[o]&&(x=R[o]);for(o=0;o<Q;++o)o%G&&(R[o]=x+V)}else for(O=!1,i=1;i<G;++i)for(o=i;o<Q;o+=G)R[o]+=U[i-1];if(S===A)for(u=1;u<H;++u){for(x=0,a=(o=u*G)+G;o<a;++o)x<J[o]&&(x=J[o]);for(o=u*G;o<a;++o)J[o]=x+K[u-1]}else if(S===q){for(x=0,o=G;o<Q;++o)x<J[o]&&(x=J[o]);for(o=G;o<Q;++o)J[o]=x+N}else for(S=!1,u=1;u<H;++u)for(a=(o=u*G)+G;o<a;++o)J[o]+=K[u-1];for(f=0,o=0;o<Q;++o)c=(d=E[o]).x||0,d.x=f=R[o]+(o%G?f:0),d.bounds.translate(f-c,0);for(i=0;i<G;++i)for(h=0,o=i;o<Q;o+=G)l=(d=E[o]).y||0,d.y=h+=J[o],d.bounds.translate(0,h-l);if(rt(r.center,P)&&H>1&&O)for(o=0;o<Q;++o)d=E[o],(f=(s=O===q?V:U[o%G])-D(d).x2)>0&&(d.x+=c=f/2,d.bounds.translate(c,0));if(rt(r.center,W)&&1!==G&&S)for(o=0;o<Q;++o)d=E[o],(h=(s=S===q?N:K[~~(o/G)])-D(d).y2)>0&&(d.y+=l=h/2,d.bounds.translate(0,l));for(o=0;o<Q;++o)E[o].mark.bounds.clear();for(o=0;o<Q;++o)d=E[o],t.dirty(d),_.union(d.mark.bounds.union(d.bounds));function X(t,e){return Math.floor(Math.min(t,e))}function Y(t,e){return Math.ceil(Math.max(t,e))}D=B?et:nt,y=rt(r.headerBand,W,null),f=it(t,g.rowheaders,E,G,H,-rt(F,"rowHeader"),X,0,D,"x1",0,G,1,y),y=rt(r.headerBand,P,null),h=it(t,g.colheaders,E,G,G,-rt(F,"columnHeader"),X,1,D,"y1",0,1,G,y),y=rt(r.footerBand,W,null),it(t,g.rowfooters,E,G,H,rt(F,"rowFooter"),Y,0,D,"x2",G-1,G,1,y),y=rt(r.footerBand,P,null),it(t,g.colfooters,E,G,G,rt(F,"columnFooter"),Y,1,D,"y2",L-G,1,G,y),g.rowtitle&&(x=f-rt(F,"rowTitle"),y=rt(r.titleBand,W,.5),ut(t,g.rowtitle,x,0,_,y)),g.coltitle&&(x=h-rt(F,"columnTitle"),y=rt(r.titleBand,P,.5),ut(t,g.coltitle,x,1,_,y))}function it(t,e,n,r,a,o,i,u,s,d,c,l,f,h){var m,b,y,x,g,p,v,k,M,w=n.length,T=0,z=0;if(!w)return T;for(m=c;m<w;m+=l)n[m]&&(T=i(T,s(n[m],d)));if(!e.length)return T;for(e.length>a&&(t.warn("Grid headers exceed limit: "+a),e=e.slice(0,a)),T+=o,b=0,x=e.length;b<x;++b)t.dirty(e[b]),e[b].mark.bounds.clear();for(m=c,b=0,x=e.length;b<x;++b,m+=l){for(g=(p=e[b]).mark.bounds,y=m;y>=0&&null==(v=n[y]);y-=f);u?(k=null==h?v.x:Math.round(v.bounds.x1+h*v.bounds.width()),M=T):(k=T,M=null==h?v.y:Math.round(v.bounds.y1+h*v.bounds.height())),g.union(p.bounds.translate(k-(p.x||0),M-(p.y||0))),p.x=k,p.y=M,t.dirty(p),z=i(z,g[d])}return z}function ut(t,e,n,r,a,o){if(e){t.dirty(e);var i=n,u=n;r?i=Math.round(a.x1+o*a.width()):u=Math.round(a.y1+o*a.height()),e.bounds.translate(i-(e.x||0),u-(e.y||0)),e.mark.bounds.clear().union(e.bounds),e.x=i,e.y=u,t.dirty(e)}}U.transform=function(t,e){var o,i,s=V[t.method]||V.parity,d=e.materialize(e.SOURCE).source,c=t.separation||0;if(d){if(!t.method)return t.modified("method")&&(Q(d),e=X(e,t)),e;if(t.sort&&(d=d.slice().sort(t.sort)),o=Q(d=d.filter(N)),e=X(e,t),o.length>=3&&K(o,c)){do{o=s(o,c)}while(o.length>=3&&K(o,c));o.length<3&&!r.peek(d).opacity&&(o.length>1&&(r.peek(o).opacity=0),r.peek(d).opacity=1)}var l,f,h,m,b;return t.boundScale&&t.boundTolerance>=0&&(l=t.boundScale,f=t.boundOrient,h=+t.boundTolerance,m=l.range(),b=new n.Bounds,f===a||f===u?b.set(m[0],-1/0,m[1],1/0):b.set(-1/0,m[0],1/0,m[1]),b.expand(h||1),i=function(t){return b.encloses(t.bounds)},d.forEach(function(t){i(t)||(t.opacity=0)})),e}},r.inherits(Y,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 r=e.source&&e.source[0];r&&(r.mark.zdirty=!0)}};var st=.5,dt=new n.Bounds;function ct(t){e.Transform.call(this,null,t)}function lt(t,e,n){return t[e]===n?0:(t[e]=n,1)}function ft(t){var e=t.items[0].datum.orient;return e===o||e===i}function ht(t,e,r,s){var d,c,l=e.items[0],f=l.datum,h=f.orient,m=function(t){var e=+t.grid;return[t.ticks?e++:-1,t.labels?e++:-1,e+ +t.domain]}(f),b=l.range,y=l.offset,x=l.position,g=l.minExtent,p=l.maxExtent,v=f.title&&l.items[m[2]].items[0],k=l.titlePadding,M=l.bounds,w=0,T=0;switch(dt.clear().union(M),M.clear(),(d=m[0])>-1&&M.union(l.items[d].bounds),(d=m[1])>-1&&M.union(l.items[d].bounds),h){case a:w=x||0,T=-y,c=Math.max(g,Math.min(p,-M.y1)),v&&(c=mt(v,c,k,0,-1,M)),M.add(0,-c).add(b,0);break;case o:w=-y,T=x||0,c=Math.max(g,Math.min(p,-M.x1)),v&&(c=mt(v,c,k,1,-1,M)),M.add(-c,0).add(0,b);break;case i:w=r+y,T=x||0,c=Math.max(g,Math.min(p,M.x2)),v&&(c=mt(v,c,k,1,1,M)),M.add(0,0).add(c,b);break;case u:w=x||0,T=s+y,c=Math.max(g,Math.min(p,M.y2)),v&&(c=mt(v,c,k,0,1,M)),M.add(0,0).add(b,c);break;default:w=l.x,T=l.y}return n.boundStroke(M.translate(w,T),l),lt(l,"x",w+st)|lt(l,"y",T+st)&&(l.bounds=dt,t.dirty(l),l.bounds=M,t.dirty(l)),l.mark.bounds.clear().union(M)}function mt(t,e,n,r,a,o){var i=t.bounds,u=0,s=0;return t.auto?(e+=n,r?u=(t.x||0)-(t.x=a*e):s=(t.y||0)-(t.y=a*e),i.translate(-u,-s),t.mark.bounds.set(i.x1,i.y1,i.x2,i.y2),r?(o.add(0,i.y1).add(0,i.y2),e+=i.width()):(o.add(i.x1,0).add(i.x2,0),e+=i.height())):o.union(i),e}function bt(t,e){return e.reduce(function(e,n){const r=n.items[0];if(function(t,e,n){var r=e.padding,a=r-n.x,s=r-n.y;if(e.datum.title){var d=e.items[1].items[0],c=d.anchor,l=e.titlePadding||0,f=r-d.x,m=r-d.y;switch(d.orient){case o:a+=Math.ceil(d.bounds.width())+l;break;case i:case u:break;default:s+=d.fontSize+l}switch((a||s)&&gt(t,n,a,s),d.orient){case o:m+=xt(e,n,d,c,0,1);break;case i:f+=xt(e,n,d,h,1,0)+l,m+=xt(e,n,d,c,0,1);break;case u:f+=xt(e,n,d,c,1,0),m+=xt(e,n,d,h,0,0,1)+l;break;default:f+=xt(e,n,d,c,1,0)}(f||m)&&gt(t,d,f,m),(f=Math.round(d.bounds.x1-r))<0&&(gt(t,n,-f,0),gt(t,d,-f,0))}else(a||s)&&gt(t,n,a,s)}(t,r,r.items[0].items[0]),r.datum.orient===o){const t=yt(r,dt.clear());e=Math.max(e,Math.ceil(t.width()+2*r.padding))}return e},0)}function yt(t,e){return t.items.forEach(t=>e.union(t.bounds)),e.x1=t.padding,e.y1=t.padding,e}function xt(t,e,n,r,a,o,i){const u="symbol"!==t.datum.type,s=n.datum.vgrad,d=(!u||!o&&s||i?e:e.items[0]).bounds[a?"x2":"y2"]-t.padding;return~~(r===f?s&&o?d:0:r===h?s&&o?0:d:.5*d)}function gt(t,e,n,r){e.x+=n,e.y+=r,e.bounds.translate(n,r),e.mark.bounds.translate(n,r),t.dirty(e)}function pt(t,e,r,f,h,m,b){var y,x,g,p,v,k=e.items[0],M=k.datum,w=M.orient,T=k.offset,z=k.bounds,E=0,D=0;switch(w===a||w===u?(g=h,E=r[w]):w!==o&&w!==i||(g=f,D=r[w]),dt.clear().union(z),z.clear(),z=yt(k,z),y=2*k.padding,x=2*k.padding,z.empty()||(y=Math.ceil(z.width()+y),x=Math.ceil(z.height()+x)),M.type===B&&(p=k.items[0].items[0].items[0].items,v=p.reduce(function(t,e){return t[e.column]=Math.max(e.bounds.x2-e.x,t[e.column]||0),t},{}),p.forEach(function(t){t.width=v[t.column],t.height=t.bounds.y2-t.y})),w){case o:E-=r.leftWidth+T-Math.floor(g.x1),r.left+=x+r.margin;break;case i:E+=T+Math.ceil(g.x2),r.right+=x+r.margin;break;case a:D-=x+T-Math.floor(g.y1),r.top+=y+r.margin;break;case u:D+=T+Math.ceil(g.y2),r.bottom+=y+r.margin;break;case s:E+=T,D+=T;break;case d:E+=m-y-T,D+=T;break;case c:E+=T,D+=b-x-T;break;case l:E+=m-y-T,D+=b-x-T;break;default:E=k.x,D=k.y}return n.boundStroke(z.set(E,D,E+y,D+x),k),lt(k,"x",E)|lt(k,"width",y)|lt(k,"y",D)|lt(k,"height",x)&&(k.bounds=dt,t.dirty(k),k.bounds=z,t.dirty(k)),k.mark.bounds.clear().union(z)}r.inherits(ct,e.Transform).transform=function(t,e){var r=e.dataflow;return t.mark.items.forEach(function(e){t.layout&&ot(r,e,t.layout),function(t,e,r){var s,d,c,l,B,q,A=e.items,I=Math.max(0,e.width||0),P=Math.max(0,e.height||0),W=(new n.Bounds).set(0,0,I,P),C=W.clone(),F=W.clone(),G=[];for(B=0,q=A.length;B<q;++B)switch((d=A[B]).role){case b:(l=ft(d)?C:F).union(ht(t,d,I,P));break;case y:s=d;break;case p:G.push(d);break;case x:case g:case v:case k:case M:case w:case T:case z:C.union(d.bounds),F.union(d.bounds);break;default:W.union(d.bounds)}if(G.length)for(c={leftWidth:bt(t,G),margin:r.legendMargin||8,left:0,right:0,top:0,bottom:0},B=0,q=G.length;B<q;++B)if(l=pt(t,G[B],c,C,F,I,P),r.autosize&&r.autosize.type===D){var H=G[B].items[0].datum.orient;H===o||H===i?W.add(l.x1,0).add(l.x2,0):H!==a&&H!==u||W.add(0,l.y1).add(0,l.y2)}else W.union(l);W.union(C).union(F),s&&W.union(function(t,e,n,r,s){var d,c=e.items[0],l=c.orient,b=c.frame,y=c.anchor,x=c.offset,g=c.bounds,p=0,v=l===o||l===i?r:n,k=0,M=0;b!==m?l===o?(p=s.y2,v=s.y1):l===i?(p=s.y1,v=s.y2):(p=s.x1,v=s.x2):l===o&&(p=r,v=0);switch(d=y===f?p:y===h?v:(p+v)/2,dt.clear().union(g),l){case a:k=d,M=s.y1-x;break;case o:k=s.x1-x,M=d;break;case i:k=s.x2+x,M=d;break;case u:k=d,M=s.y2+x;break;default:k=c.x,M=c.y}g.translate(k-(c.x||0),M-(c.y||0)),lt(c,"x",k)|lt(c,"y",M)&&(c.bounds=dt,t.dirty(c),c.bounds=g,t.dirty(c));return e.bounds.clear().union(g)}(t,s,I,P,W));!function(t,e,n,r){var a=r.autosize||{},o=a.type,i=t._width,u=t._height,s=t.padding();if(t._autosize<1||!o)return;var d=Math.max(0,e.width||0),c=Math.max(0,Math.ceil(-n.x1)),l=Math.max(0,Math.ceil(n.x2-d)),f=Math.max(0,e.height||0),h=Math.max(0,Math.ceil(-n.y1)),m=Math.max(0,Math.ceil(n.y2-f));a.contains===E&&(i-=s.left+s.right,u-=s.top+s.bottom);o===j?(c=0,h=0,d=i,f=u):o===D?(d=Math.max(0,i-c-l),f=Math.max(0,u-h-m)):o===_?(d=Math.max(0,i-c-l),u=f+h+m):o===O?(i=d+c+l,f=Math.max(0,u-h-m)):o===S&&(i=d+c+l,u=f+h+m);t._resizeView(i,u,d,f,[c,h],a.resize)}(t,e,W,r)}(r,e,t)}),t.modified()&&e.reflow(),e},t.bound=C,t.identifier=H,t.mark=L,t.overlap=R,t.render=Y,t.viewlayout=ct,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "vega-view-transforms",
"version": "4.0.1",
"version": "4.1.0",
"description": "View-specific transforms for Vega dataflows.",

@@ -26,6 +26,7 @@ "keywords": [

"dependencies": {
"vega-dataflow": "^5.1.0",
"vega-scenegraph": "^4.0.0",
"vega-dataflow": "^5.1.1",
"vega-scenegraph": "^4.0.2",
"vega-util": "^1.8.0"
}
},
"gitHead": "0f0e009069ae0291458398a747f024c693c201d9"
}

@@ -283,3 +283,3 @@ import {

bounds.translate(x - item.x, y - item.y);
bounds.translate(x - (item.x || 0), y - (item.y || 0));
if (set(item, 'x', x) | set(item, 'y', y)) {

@@ -298,3 +298,3 @@ item.bounds = tempBounds;

return legends.reduce(function(w, legend) {
var item = legend.items[0];
const item = legend.items[0];

@@ -304,6 +304,6 @@ // adjust entry to accommodate padding and title

// if left-oriented, calculate maximum legend width
if (item.datum.orient === Left) {
var b = tempBounds.clear();
item.items.forEach(function(_) { b.union(_.bounds); });
w = Math.max(w, Math.ceil(b.width() + 2 * item.padding - 1));
const b = legendBounds(item, tempBounds.clear());
w = Math.max(w, Math.ceil(b.width() + 2 * item.padding));
}

@@ -315,20 +315,83 @@

function legendBounds(item, b) {
// aggregate item bounds
item.items.forEach(_ => b.union(_.bounds));
// anchor to legend origin
b.x1 = item.padding;
b.y1 = item.padding;
return b;
}
function legendGroupLayout(view, item, entry) {
var x = item.padding - entry.x,
y = item.padding - entry.y;
var pad = item.padding,
ex = pad - entry.x,
ey = pad - entry.y;
if (item.datum.title) {
var title = item.items[1].items[0];
y += item.titlePadding + title.fontSize;
}
if (!item.datum.title) {
if (ex || ey) translate(view, entry, ex, ey);
} else {
var title = item.items[1].items[0],
anchor = title.anchor,
tpad = item.titlePadding || 0,
tx = pad - title.x,
ty = pad - title.y;
if (x || y) {
entry.x += x;
entry.y += y;
entry.bounds.translate(x, y);
entry.mark.bounds.translate(x, y);
view.dirty(entry);
switch (title.orient) {
case Left:
ex += Math.ceil(title.bounds.width()) + tpad;
break;
case Right:
case Bottom:
break;
default:
ey += title.fontSize + tpad;
}
if (ex || ey) translate(view, entry, ex, ey);
switch (title.orient) {
case Left:
ty += legendTitleOffset(item, entry, title, anchor, 0, 1);
break;
case Right:
tx += legendTitleOffset(item, entry, title, End, 1, 0) + tpad;
ty += legendTitleOffset(item, entry, title, anchor, 0, 1);
break;
case Bottom:
tx += legendTitleOffset(item, entry, title, anchor, 1, 0);
ty += legendTitleOffset(item, entry, title, End, 0, 0, 1) + tpad;
break;
default:
tx += legendTitleOffset(item, entry, title, anchor, 1, 0);
}
if (tx || ty) translate(view, title, tx, ty);
// translate legend if title pushes into negative coordinates
if ((tx = Math.round(title.bounds.x1 - pad)) < 0) {
translate(view, entry, -tx, 0);
translate(view, title, -tx, 0);
}
}
}
function legendTitleOffset(item, entry, title, anchor, x, lr, noBar) {
const grad = item.datum.type !== 'symbol',
vgrad = title.datum.vgrad,
e = grad && (lr || !vgrad) && !noBar ? entry.items[0] : entry,
s = e.bounds[x ? 'x2' : 'y2'] - item.padding,
u = vgrad && lr ? s : 0,
v = vgrad && lr ? 0 : s;
return ~~(anchor === Start ? u : anchor === End ? v : 0.5 * s);
}
function translate(view, item, dx, dy) {
item.x += dx;
item.y += dy;
item.bounds.translate(dx, dy);
item.mark.bounds.translate(dx, dy);
view.dirty(item);
}
function legendLayout(view, legend, flow, xBounds, yBounds, width, height) {

@@ -355,7 +418,6 @@ var item = legend.items[0],

// aggregate bounds to determine size
// shave off 1 pixel because it looks better...
item.items.forEach(function(_) { bounds.union(_.bounds); });
w = 2 * item.padding - 1;
h = 2 * item.padding - 1;
// aggregate bounds to determine size, and include origin
bounds = legendBounds(item, bounds);
w = 2 * item.padding;
h = 2 * item.padding;
if (!bounds.empty()) {

@@ -362,0 +424,0 @@ w = Math.ceil(bounds.width() + w);

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