Socket
Socket
Sign inDemoInstall

vega-label

Package Overview
Dependencies
30
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.0.5

6

build/vega-label.js

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

function placeAreaLabelNaive($, bitmaps, avoidBaseMark, markIndex) {
let width = $.width,
const width = $.width,
height = $.height;

@@ -284,3 +284,3 @@

function placeAreaLabelReducedSearch($, bitmaps, avoidBaseMark, markIndex) {
let width = $.width,
const width = $.width,
height = $.height,

@@ -418,3 +418,3 @@ bm0 = bitmaps[0], // where labels have been placed

function placeAreaLabelFloodFill($, bitmaps, avoidBaseMark, markIndex) {
let width = $.width,
const width = $.width,
height = $.height,

@@ -421,0 +421,0 @@ bm0 = bitmaps[0], // where labels have been placed

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-canvas"),require("vega-dataflow"),require("vega-scenegraph"),require("vega-util")):"function"==typeof define&&define.amd?define(["exports","vega-canvas","vega-dataflow","vega-scenegraph","vega-util"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).vega=t.vega||{},t.vega.transforms={}),t.vega,t.vega,t.vega,t.vega)}(this,(function(t,e,n,r,a){"use strict";function i(t,n,a,i){const u=t.width,s=t.height,f=a||i,l=e.canvas(u,s).getContext("2d");n.forEach(t=>function t(e,n,a){if(!n.length)return;const i=n[0].mark.marktype;"group"===i?n.forEach(n=>{n.items.forEach(n=>t(e,n.items,a))}):r.Marks[i].draw(e,{items:a?n.map(o):n})}(l,t,f));const d=new Uint32Array(l.getImageData(0,0,u,s).data.buffer),c=t.bitmap(),m=f&&t.bitmap();let g,h,y,p,x;for(h=0;h<s;++h)for(g=0;g<u;++g)x=4278190080&d[h*u+g],x&&(y=t(g),p=t(h),i||c.set(y,p),f&&268435456^x&&m.set(y,p));return[c,m]}function o(t){const e=n.rederive(t,{});return e.stroke&&(e.strokeOpacity=1),e.fill&&(e.fillOpacity=.0625,e.stroke="#000",e.strokeOpacity=1,e.strokeWidth=2),e}const u=new Uint32Array(33),s=new Uint32Array(33);s[0]=0,u[0]=~s[0];for(let t=1;t<=32;++t)s[t]=s[t-1]<<1|1,u[t]=~s[t];function f(t,e,n){const r=Math.max(1,Math.sqrt(t*e/1e6)),a=~~((t+2*n+r)/r),i=~~((e+2*n+r)/r),o=t=>~~((t+n)/r);return o.invert=t=>t*r-n,o.bitmap=()=>function(t,e){const n=new Uint32Array(~~((t*e+32)/32));function r(t,e){n[t]|=e}function a(t,e){n[t]&=e}return{array:n,get:(e,r)=>{const a=r*t+e;return n[a>>>5]&1<<(31&a)},set:(e,n)=>{const a=n*t+e;r(a>>>5,1<<(31&a))},clear:(e,n)=>{const r=n*t+e;a(r>>>5,~(1<<(31&r)))},getRange:(e,r,a,i)=>{let o,f,l,d,c=i;for(;c>=r;--c)if(o=c*t+e,f=c*t+a,l=o>>>5,d=f>>>5,l===d){if(n[l]&u[31&o]&s[1+(31&f)])return!0}else{if(n[l]&u[31&o])return!0;if(n[d]&s[1+(31&f)])return!0;for(let t=l+1;t<d;++t)if(n[t])return!0}return!1},setRange:(e,n,a,i)=>{let o,f,l,d,c;for(;n<=i;++n)if(o=n*t+e,f=n*t+a,l=o>>>5,d=f>>>5,l===d)r(l,u[31&o]&s[1+(31&f)]);else for(r(l,u[31&o]),r(d,s[1+(31&f)]),c=l+1;c<d;++c)r(c,4294967295)},clearRange:(e,n,r,i)=>{let o,f,l,d,c;for(;n<=i;++n)if(o=n*t+e,f=n*t+r,l=o>>>5,d=f>>>5,l===d)a(l,s[31&o]|u[1+(31&f)]);else for(a(l,s[31&o]),a(d,u[1+(31&f)]),c=l+1;c<d;++c)a(c,0)},outOfBounds:(n,r,a,i)=>n<0||r<0||i>=e||a>=t}}(a,i),o.ratio=r,o.padding=n,o.width=t,o.height=e,o}function l(t,e,n,r,a,i){let o=n/2;return t-o<0||t+o>a||e-(o=r/2)<0||e+o>i}function d(t,e,n,r,a,i,o,u){const s=a*i/(2*r),f=t(e-s),l=t(e+s),d=t(n-(i/=2)),c=t(n+i);return o.outOfBounds(f,d,l,c)||o.getRange(f,d,l,c)||u&&u.getRange(f,d,l,c)}const c=[-1,-1,1,1],m=[-1,1,-1,1];const g=["right","center","left"],h=["bottom","middle","top"];function y(t,e,n,r,a,i,o,u,s,f,l,d){return!(a.outOfBounds(t,n,e,r)||(d&&i?i.getRange(t,n,e,r)||!function(t,e,n,r,a){return a[0]<=t&&n<=a[2]&&a[3]<=e&&r<=a[5]}(o,s,u,f,l):a.getRange(t,n,e,r)))}const p={"top-left":0,top:1,"top-right":2,left:4,middle:5,right:6,"bottom-left":8,bottom:9,"bottom-right":10},x={naive:function(t,e,n,a){let i=t.width,o=t.height;return function(t){const e=t.datum.datum.items[a].items,n=e.length,u=t.datum.fontSize,s=r.textMetrics.width(t.datum,t.datum.text);let f,l,d,c,m,g,h,y=0;for(let r=0;r<n;++r)f=e[r].x,d=e[r].y,l=void 0===e[r].x2?f:e[r].x2,c=void 0===e[r].y2?d:e[r].y2,m=(f+l)/2,g=(d+c)/2,h=Math.abs(l-f+c-d),h>=y&&(y=h,t.x=m,t.y=g);return m=s/2,g=u/2,f=t.x-m,l=t.x+m,d=t.y-g,c=t.y+g,t.align="center",f<0&&l<=i?t.align="left":0<=f&&i<l&&(t.align="right"),t.baseline="middle",d<0&&c<=o?t.baseline="top":0<=d&&o<c&&(t.baseline="bottom"),!0}},"reduced-search":function(t,e,n,a){let i=t.width,o=t.height,u=e[0],s=e[1];function f(e,n,r,a,f){const c=t.invert(e),m=t.invert(n);let g,h=r,y=o;if(!l(c,m,a,f,i,o)&&!d(t,c,m,f,a,h,u,s)&&!d(t,c,m,f,a,f,u,null)){for(;y-h>=1;)g=(h+y)/2,d(t,c,m,f,a,g,u,s)?y=g:h=g;if(h>r)return[c,m,h,!0]}}return function(e){const s=e.datum.datum.items[a].items,c=s.length,m=e.datum.fontSize,g=r.textMetrics.width(e.datum,e.datum.text);let h,y,p,x,v,b,w,k,M,R,z,A,O,E,S,q,B,T=n?m:0,U=!1,D=!1,I=0;for(let r=0;r<c;++r){for(h=s[r].x,p=s[r].y,y=void 0===s[r].x2?h:s[r].x2,x=void 0===s[r].y2?p:s[r].y2,h>y&&(B=h,h=y,y=B),p>x&&(B=p,p=x,x=B),M=t(h),z=t(y),R=~~((M+z)/2),A=t(p),E=t(x),O=~~((A+E)/2),w=R;w>=M;--w)for(k=O;k>=A;--k)q=f(w,k,T,g,m),q&&([e.x,e.y,T,U]=q);for(w=R;w<=z;++w)for(k=O;k<=E;++k)q=f(w,k,T,g,m),q&&([e.x,e.y,T,U]=q);U||n||(S=Math.abs(y-h+x-p),v=(h+y)/2,b=(p+x)/2,S>=I&&!l(v,b,g,m,i,o)&&!d(t,v,b,m,g,m,u,null)&&(I=S,e.x=v,e.y=b,D=!0))}return!(!U&&!D)&&(v=g/2,b=m/2,u.setRange(t(e.x-v),t(e.y-b),t(e.x+v),t(e.y+b)),e.align="center",e.baseline="middle",!0)}},floodfill:function(t,e,n,a){let i=t.width,o=t.height,u=e[0],s=e[1],f=t.bitmap();return function(e){const g=e.datum.datum.items[a].items,h=g.length,y=e.datum.fontSize,p=r.textMetrics.width(e.datum,e.datum.text),x=[];let v,b,w,k,M,R,z,A,O,E,S,q,B=n?y:0,T=!1,U=!1,D=0;for(let r=0;r<h;++r){for(v=g[r].x,w=g[r].y,b=void 0===g[r].x2?v:g[r].x2,k=void 0===g[r].y2?w:g[r].y2,x.push([t((v+b)/2),t((w+k)/2)]);x.length;)if([z,A]=x.pop(),!(u.get(z,A)||s.get(z,A)||f.get(z,A))){f.set(z,A);for(let t=0;t<4;++t)M=z+c[t],R=A+m[t],f.outOfBounds(M,R,M,R)||x.push([M,R]);if(M=t.invert(z),R=t.invert(A),O=B,E=o,!l(M,R,p,y,i,o)&&!d(t,M,R,y,p,O,u,s)&&!d(t,M,R,y,p,y,u,null)){for(;E-O>=1;)S=(O+E)/2,d(t,M,R,y,p,S,u,s)?E=S:O=S;O>B&&(e.x=M,e.y=R,B=O,T=!0)}}T||n||(q=Math.abs(b-v+k-w),M=(v+b)/2,R=(w+k)/2,q>=D&&!l(M,R,p,y,i,o)&&!d(t,M,R,y,p,y,u,null)&&(D=q,e.x=M,e.y=R,U=!0))}return!(!T&&!U)&&(M=p/2,R=y/2,u.setRange(t(e.x-M),t(e.y-R),t(e.x+M),t(e.y+R)),e.align="center",e.baseline="middle",!0)}}};function v(t,e,n,a,o,u,s,l,d,c,m){if(!t.length)return t;const v=Math.max(a.length,o.length),b=function(t,e){const n=new Float64Array(e),r=t.length;for(let e=0;e<r;++e)n[e]=t[e]||0;for(let t=r;t<e;++t)n[t]=n[r-1];return n}(a,v),w=function(t,e){const n=new Int8Array(e),r=t.length;for(let e=0;e<r;++e)n[e]|=p[t[e]];for(let t=r;t<e;++t)n[t]=n[r-1];return n}(o,v),k=(E=t[0].datum)&&E.mark&&E.mark.marktype,M="group"===k&&t[0].datum.items[d].marktype,R="area"===M,z=function(t,e,n,r){const a=t=>[t.x,t.x,t.x,t.y,t.y,t.y];return t?"line"===t||"area"===t?t=>a(t.datum):"line"===e?t=>{const e=t.datum.items[r].items;return a(e.length?e["start"===n?0:e.length-1]:{x:NaN,y:NaN})}:t=>{const e=t.datum.bounds;return[e.x1,(e.x1+e.x2)/2,e.x2,e.y1,(e.y1+e.y2)/2,e.y2]}:a}(k,M,l,d),A=f(e[0],e[1],c),O=R&&"naive"===m;var E;const S=t.map(t=>({datum:t,opacity:0,x:void 0,y:void 0,align:void 0,baseline:void 0,boundary:z(t)}));let q;if(!O){n&&S.sort((t,e)=>n(t.datum,e.datum));let e=!1;for(let t=0;t<w.length&&!e;++t)e=5===w[t]||b[t]<0;k&&(s||R)&&(u=[t.map(t=>t.datum)].concat(u)),q=u.length?i(A,u,e,R):function(t,e){const n=t.bitmap();return(e||[]).forEach(e=>n.set(t(e.boundary[0]),t(e.boundary[3]))),[n,void 0]}(A,s&&S)}const B=R?x[m](A,q,s,d):function(t,e,n,a){const i=t.width,o=t.height,u=e[0],s=e[1],f=a.length;return function(e){const l=e.boundary,d=e.datum.fontSize;if(l[2]<0||l[5]<0||l[0]>i||l[3]>o)return!1;let c,m,p,x,v,b,w,k,M,R,z,A,O,E,S,q=0;for(let i=0;i<f;++i){if(c=(3&n[i])-1,m=(n[i]>>>2&3)-1,p=0===c&&0===m||a[i]<0,x=c&&m?Math.SQRT1_2:1,v=a[i]<0?-1:1,b=l[1+c]+a[i]*c*x,z=l[4+m]+v*d*m/2+a[i]*m*x,k=z-d/2,M=z+d/2,A=t(b),E=t(k),S=t(M),!q){if(!y(A,A,E,S,u,s,b,b,k,M,l,p))continue;q=r.textMetrics.width(e.datum,e.datum.text)}if(R=b+v*q*c/2,b=R-q/2,w=R+q/2,A=t(b),O=t(w),y(A,O,E,S,u,s,b,w,k,M,l,p))return e.x=c?c*v<0?w:b:R,e.y=m?m*v<0?M:k:z,e.align=g[c*v+1],e.baseline=h[m*v+1],u.setRange(A,E,O,S),!0}return!1}}(A,q,w,b);return S.forEach(t=>t.opacity=+B(t)),S}const b=["x","y","opacity","align","baseline"],w=["top-left","left","bottom-left","top","bottom","top-right","right","bottom-right"];function k(t){n.Transform.call(this,null,t)}k.Definition={type:"Label",metadata:{modifies:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"sort",type:"compare"},{name:"anchor",type:"string",array:!0,default:w},{name:"offset",type:"number",array:!0,default:[1]},{name:"padding",type:"number",default:0},{name:"lineAnchor",type:"string",values:["start","end"],default:"end"},{name:"markIndex",type:"number",default:0},{name:"avoidBaseMark",type:"boolean",default:!0},{name:"avoidMarks",type:"data",array:!0},{name:"method",type:"string",default:"naive"},{name:"as",type:"string",array:!0,length:b.length,default:b}]},a.inherits(k,n.Transform,{transform(t,e){const n=t.modified();if(!(n||e.changed(e.ADD_REM)||function(n){const r=t[n];return a.isFunction(r)&&e.modified(r.fields)}("sort")))return;t.size&&2===t.size.length||a.error("Size parameter should be specified as a [width, height] array.");const r=t.as||b;return v(e.materialize(e.SOURCE).source,t.size,t.sort,a.array(t.offset||1),a.array(t.anchor||w),t.avoidMarks||[],!1!==t.avoidBaseMark,t.lineAnchor||"end",t.markIndex||0,t.padding||0,t.method||"naive").forEach(t=>{const e=t.datum;e[r[0]]=t.x,e[r[1]]=t.y,e[r[2]]=t.opacity,e[r[3]]=t.align,e[r[4]]=t.baseline}),e.reflow(n).modifies(r)}}),t.label=k,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-canvas"),require("vega-dataflow"),require("vega-scenegraph"),require("vega-util")):"function"==typeof define&&define.amd?define(["exports","vega-canvas","vega-dataflow","vega-scenegraph","vega-util"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).vega=t.vega||{},t.vega.transforms={}),t.vega,t.vega,t.vega,t.vega)}(this,(function(t,e,n,r,a){"use strict";function i(t,n,a,i){const u=t.width,s=t.height,f=a||i,l=e.canvas(u,s).getContext("2d");n.forEach(t=>function t(e,n,a){if(!n.length)return;const i=n[0].mark.marktype;"group"===i?n.forEach(n=>{n.items.forEach(n=>t(e,n.items,a))}):r.Marks[i].draw(e,{items:a?n.map(o):n})}(l,t,f));const d=new Uint32Array(l.getImageData(0,0,u,s).data.buffer),c=t.bitmap(),m=f&&t.bitmap();let g,h,y,p,x;for(h=0;h<s;++h)for(g=0;g<u;++g)x=4278190080&d[h*u+g],x&&(y=t(g),p=t(h),i||c.set(y,p),f&&268435456^x&&m.set(y,p));return[c,m]}function o(t){const e=n.rederive(t,{});return e.stroke&&(e.strokeOpacity=1),e.fill&&(e.fillOpacity=.0625,e.stroke="#000",e.strokeOpacity=1,e.strokeWidth=2),e}const u=31,s=new Uint32Array(33),f=new Uint32Array(33);f[0]=0,s[0]=~f[0];for(let t=1;t<=32;++t)f[t]=f[t-1]<<1|1,s[t]=~f[t];function l(t,e,n){const r=Math.max(1,Math.sqrt(t*e/1e6)),a=~~((t+2*n+r)/r),i=~~((e+2*n+r)/r),o=t=>~~((t+n)/r);return o.invert=t=>t*r-n,o.bitmap=()=>function(t,e){const n=new Uint32Array(~~((t*e+32)/32));function r(t,e){n[t]|=e}function a(t,e){n[t]&=e}return{array:n,get:(e,r)=>{const a=r*t+e;return n[a>>>5]&1<<(a&u)},set:(e,n)=>{const a=n*t+e;r(a>>>5,1<<(a&u))},clear:(e,n)=>{const r=n*t+e;a(r>>>5,~(1<<(r&u)))},getRange:(e,r,a,i)=>{let o,l,d,c,m=i;for(;m>=r;--m)if(o=m*t+e,l=m*t+a,d=o>>>5,c=l>>>5,d===c){if(n[d]&s[o&u]&f[1+(l&u)])return!0}else{if(n[d]&s[o&u])return!0;if(n[c]&f[1+(l&u)])return!0;for(let t=d+1;t<c;++t)if(n[t])return!0}return!1},setRange:(e,n,a,i)=>{let o,l,d,c,m;for(;n<=i;++n)if(o=n*t+e,l=n*t+a,d=o>>>5,c=l>>>5,d===c)r(d,s[o&u]&f[1+(l&u)]);else for(r(d,s[o&u]),r(c,f[1+(l&u)]),m=d+1;m<c;++m)r(m,4294967295)},clearRange:(e,n,r,i)=>{let o,l,d,c,m;for(;n<=i;++n)if(o=n*t+e,l=n*t+r,d=o>>>5,c=l>>>5,d===c)a(d,f[o&u]|s[1+(l&u)]);else for(a(d,f[o&u]),a(c,s[1+(l&u)]),m=d+1;m<c;++m)a(m,0)},outOfBounds:(n,r,a,i)=>n<0||r<0||i>=e||a>=t}}(a,i),o.ratio=r,o.padding=n,o.width=t,o.height=e,o}function d(t,e,n,r,a,i){let o=n/2;return t-o<0||t+o>a||e-(o=r/2)<0||e+o>i}function c(t,e,n,r,a,i,o,u){const s=a*i/(2*r),f=t(e-s),l=t(e+s),d=t(n-(i/=2)),c=t(n+i);return o.outOfBounds(f,d,l,c)||o.getRange(f,d,l,c)||u&&u.getRange(f,d,l,c)}const m=[-1,-1,1,1],g=[-1,1,-1,1];const h=["right","center","left"],y=["bottom","middle","top"];function p(t,e,n,r,a,i,o,u,s,f,l,d){return!(a.outOfBounds(t,n,e,r)||(d&&i?i.getRange(t,n,e,r)||!function(t,e,n,r,a){return a[0]<=t&&n<=a[2]&&a[3]<=e&&r<=a[5]}(o,s,u,f,l):a.getRange(t,n,e,r)))}const x={"top-left":0,top:1,"top-right":2,left:4,middle:5,right:6,"bottom-left":8,bottom:9,"bottom-right":10},v={naive:function(t,e,n,a){const i=t.width,o=t.height;return function(t){const e=t.datum.datum.items[a].items,n=e.length,u=t.datum.fontSize,s=r.textMetrics.width(t.datum,t.datum.text);let f,l,d,c,m,g,h,y=0;for(let r=0;r<n;++r)f=e[r].x,d=e[r].y,l=void 0===e[r].x2?f:e[r].x2,c=void 0===e[r].y2?d:e[r].y2,m=(f+l)/2,g=(d+c)/2,h=Math.abs(l-f+c-d),h>=y&&(y=h,t.x=m,t.y=g);return m=s/2,g=u/2,f=t.x-m,l=t.x+m,d=t.y-g,c=t.y+g,t.align="center",f<0&&l<=i?t.align="left":0<=f&&i<l&&(t.align="right"),t.baseline="middle",d<0&&c<=o?t.baseline="top":0<=d&&o<c&&(t.baseline="bottom"),!0}},"reduced-search":function(t,e,n,a){const i=t.width,o=t.height,u=e[0],s=e[1];function f(e,n,r,a,f){const l=t.invert(e),m=t.invert(n);let g,h=r,y=o;if(!d(l,m,a,f,i,o)&&!c(t,l,m,f,a,h,u,s)&&!c(t,l,m,f,a,f,u,null)){for(;y-h>=1;)g=(h+y)/2,c(t,l,m,f,a,g,u,s)?y=g:h=g;if(h>r)return[l,m,h,!0]}}return function(e){const s=e.datum.datum.items[a].items,l=s.length,m=e.datum.fontSize,g=r.textMetrics.width(e.datum,e.datum.text);let h,y,p,x,v,b,w,k,M,R,z,A,O,E,S,q,B,T=n?m:0,U=!1,D=!1,I=0;for(let r=0;r<l;++r){for(h=s[r].x,p=s[r].y,y=void 0===s[r].x2?h:s[r].x2,x=void 0===s[r].y2?p:s[r].y2,h>y&&(B=h,h=y,y=B),p>x&&(B=p,p=x,x=B),M=t(h),z=t(y),R=~~((M+z)/2),A=t(p),E=t(x),O=~~((A+E)/2),w=R;w>=M;--w)for(k=O;k>=A;--k)q=f(w,k,T,g,m),q&&([e.x,e.y,T,U]=q);for(w=R;w<=z;++w)for(k=O;k<=E;++k)q=f(w,k,T,g,m),q&&([e.x,e.y,T,U]=q);U||n||(S=Math.abs(y-h+x-p),v=(h+y)/2,b=(p+x)/2,S>=I&&!d(v,b,g,m,i,o)&&!c(t,v,b,m,g,m,u,null)&&(I=S,e.x=v,e.y=b,D=!0))}return!(!U&&!D)&&(v=g/2,b=m/2,u.setRange(t(e.x-v),t(e.y-b),t(e.x+v),t(e.y+b)),e.align="center",e.baseline="middle",!0)}},floodfill:function(t,e,n,a){const i=t.width,o=t.height,u=e[0],s=e[1],f=t.bitmap();return function(e){const l=e.datum.datum.items[a].items,h=l.length,y=e.datum.fontSize,p=r.textMetrics.width(e.datum,e.datum.text),x=[];let v,b,w,k,M,R,z,A,O,E,S,q,B=n?y:0,T=!1,U=!1,D=0;for(let r=0;r<h;++r){for(v=l[r].x,w=l[r].y,b=void 0===l[r].x2?v:l[r].x2,k=void 0===l[r].y2?w:l[r].y2,x.push([t((v+b)/2),t((w+k)/2)]);x.length;)if([z,A]=x.pop(),!(u.get(z,A)||s.get(z,A)||f.get(z,A))){f.set(z,A);for(let t=0;t<4;++t)M=z+m[t],R=A+g[t],f.outOfBounds(M,R,M,R)||x.push([M,R]);if(M=t.invert(z),R=t.invert(A),O=B,E=o,!d(M,R,p,y,i,o)&&!c(t,M,R,y,p,O,u,s)&&!c(t,M,R,y,p,y,u,null)){for(;E-O>=1;)S=(O+E)/2,c(t,M,R,y,p,S,u,s)?E=S:O=S;O>B&&(e.x=M,e.y=R,B=O,T=!0)}}T||n||(q=Math.abs(b-v+k-w),M=(v+b)/2,R=(w+k)/2,q>=D&&!d(M,R,p,y,i,o)&&!c(t,M,R,y,p,y,u,null)&&(D=q,e.x=M,e.y=R,U=!0))}return!(!T&&!U)&&(M=p/2,R=y/2,u.setRange(t(e.x-M),t(e.y-R),t(e.x+M),t(e.y+R)),e.align="center",e.baseline="middle",!0)}}};function b(t,e,n,a,o,u,s,f,d,c,m){if(!t.length)return t;const g=Math.max(a.length,o.length),b=function(t,e){const n=new Float64Array(e),r=t.length;for(let e=0;e<r;++e)n[e]=t[e]||0;for(let t=r;t<e;++t)n[t]=n[r-1];return n}(a,g),w=function(t,e){const n=new Int8Array(e),r=t.length;for(let e=0;e<r;++e)n[e]|=x[t[e]];for(let t=r;t<e;++t)n[t]=n[r-1];return n}(o,g),k=(E=t[0].datum)&&E.mark&&E.mark.marktype,M="group"===k&&t[0].datum.items[d].marktype,R="area"===M,z=function(t,e,n,r){const a=t=>[t.x,t.x,t.x,t.y,t.y,t.y];return t?"line"===t||"area"===t?t=>a(t.datum):"line"===e?t=>{const e=t.datum.items[r].items;return a(e.length?e["start"===n?0:e.length-1]:{x:NaN,y:NaN})}:t=>{const e=t.datum.bounds;return[e.x1,(e.x1+e.x2)/2,e.x2,e.y1,(e.y1+e.y2)/2,e.y2]}:a}(k,M,f,d),A=l(e[0],e[1],c),O=R&&"naive"===m;var E;const S=t.map(t=>({datum:t,opacity:0,x:void 0,y:void 0,align:void 0,baseline:void 0,boundary:z(t)}));let q;if(!O){n&&S.sort((t,e)=>n(t.datum,e.datum));let e=!1;for(let t=0;t<w.length&&!e;++t)e=5===w[t]||b[t]<0;k&&(s||R)&&(u=[t.map(t=>t.datum)].concat(u)),q=u.length?i(A,u,e,R):function(t,e){const n=t.bitmap();return(e||[]).forEach(e=>n.set(t(e.boundary[0]),t(e.boundary[3]))),[n,void 0]}(A,s&&S)}const B=R?v[m](A,q,s,d):function(t,e,n,a){const i=t.width,o=t.height,u=e[0],s=e[1],f=a.length;return function(e){const l=e.boundary,d=e.datum.fontSize;if(l[2]<0||l[5]<0||l[0]>i||l[3]>o)return!1;let c,m,g,x,v,b,w,k,M,R,z,A,O,E,S,q=0;for(let i=0;i<f;++i){if(c=(3&n[i])-1,m=(n[i]>>>2&3)-1,g=0===c&&0===m||a[i]<0,x=c&&m?Math.SQRT1_2:1,v=a[i]<0?-1:1,b=l[1+c]+a[i]*c*x,z=l[4+m]+v*d*m/2+a[i]*m*x,k=z-d/2,M=z+d/2,A=t(b),E=t(k),S=t(M),!q){if(!p(A,A,E,S,u,s,b,b,k,M,l,g))continue;q=r.textMetrics.width(e.datum,e.datum.text)}if(R=b+v*q*c/2,b=R-q/2,w=R+q/2,A=t(b),O=t(w),p(A,O,E,S,u,s,b,w,k,M,l,g))return e.x=c?c*v<0?w:b:R,e.y=m?m*v<0?M:k:z,e.align=h[c*v+1],e.baseline=y[m*v+1],u.setRange(A,E,O,S),!0}return!1}}(A,q,w,b);return S.forEach(t=>t.opacity=+B(t)),S}const w=["x","y","opacity","align","baseline"],k=["top-left","left","bottom-left","top","bottom","top-right","right","bottom-right"];function M(t){n.Transform.call(this,null,t)}M.Definition={type:"Label",metadata:{modifies:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"sort",type:"compare"},{name:"anchor",type:"string",array:!0,default:k},{name:"offset",type:"number",array:!0,default:[1]},{name:"padding",type:"number",default:0},{name:"lineAnchor",type:"string",values:["start","end"],default:"end"},{name:"markIndex",type:"number",default:0},{name:"avoidBaseMark",type:"boolean",default:!0},{name:"avoidMarks",type:"data",array:!0},{name:"method",type:"string",default:"naive"},{name:"as",type:"string",array:!0,length:w.length,default:w}]},a.inherits(M,n.Transform,{transform(t,e){const n=t.modified();if(!(n||e.changed(e.ADD_REM)||function(n){const r=t[n];return a.isFunction(r)&&e.modified(r.fields)}("sort")))return;t.size&&2===t.size.length||a.error("Size parameter should be specified as a [width, height] array.");const r=t.as||w;return b(e.materialize(e.SOURCE).source,t.size,t.sort,a.array(t.offset||1),a.array(t.anchor||k),t.avoidMarks||[],!1!==t.avoidBaseMark,t.lineAnchor||"end",t.markIndex||0,t.padding||0,t.method||"naive").forEach(t=>{const e=t.datum;e[r[0]]=t.x,e[r[1]]=t.y,e[r[2]]=t.opacity,e[r[3]]=t.align,e[r[4]]=t.baseline}),e.reflow(n).modifies(r)}}),t.label=M,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "vega-label",
"version": "0.0.4",
"version": "0.0.5",
"description": "Label layout transform for Vega dataflows.",

@@ -29,6 +29,6 @@ "keywords": [

"dependencies": {
"vega-canvas": "^1.2.3",
"vega-dataflow": "^5.7.1",
"vega-scenegraph": "^4.9.0",
"vega-util": "^1.15.0"
"vega-canvas": "^1.2.4",
"vega-dataflow": "^5.7.2",
"vega-scenegraph": "^4.9.1",
"vega-util": "^1.15.1"
},

@@ -38,3 +38,3 @@ "devDependencies": {

},
"gitHead": "28db83352e43e321dfe55fc5cb6489b211e45662"
"gitHead": "8d6793f4ca7eaaf2d22186764e9ce2dae687cf52"
}

@@ -9,3 +9,3 @@ import {textMetrics} from 'vega-scenegraph';

export default function($, bitmaps, avoidBaseMark, markIndex) {
let width = $.width,
const width = $.width,
height = $.height,

@@ -12,0 +12,0 @@ bm0 = bitmaps[0], // where labels have been placed

import {textMetrics} from 'vega-scenegraph';
export default function($, bitmaps, avoidBaseMark, markIndex) {
let width = $.width,
const width = $.width,
height = $.height;

@@ -6,0 +6,0 @@

@@ -5,3 +5,3 @@ import {textMetrics} from 'vega-scenegraph';

export default function($, bitmaps, avoidBaseMark, markIndex) {
let width = $.width,
const width = $.width,
height = $.height,

@@ -8,0 +8,0 @@ bm0 = bitmaps[0], // where labels have been placed

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