Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vega-wordcloud

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-wordcloud - npm Package Compare versions

Comparing version 4.1.1 to 4.1.2

38

build/vega-wordcloud.js

@@ -64,22 +64,20 @@ (function (global, factory) {

tags = [],
data = words.map(function(d) {
return {
text: text(d),
font: font(d),
style: fontStyle(d),
weight: fontWeight(d),
rotate: rotate(d),
size: ~~(fontSize(d) + 1e-14),
padding: padding(d),
xoff: 0,
yoff: 0,
x1: 0,
y1: 0,
x0: 0,
y0: 0,
hasText: false,
sprite: null,
datum: d
};
}).sort(function(a, b) { return b.size - a.size; });
data = words.map(d => ({
text: text(d),
font: font(d),
style: fontStyle(d),
weight: fontWeight(d),
rotate: rotate(d),
size: ~~(fontSize(d) + 1e-14),
padding: padding(d),
xoff: 0,
yoff: 0,
x1: 0,
y1: 0,
x0: 0,
y0: 0,
hasText: false,
sprite: null,
datum: d
})).sort((a, b) => b.size - a.size);

@@ -86,0 +84,0 @@ while (++i < n) {

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-canvas"),require("vega-dataflow"),require("vega-util"),require("vega-scale"),require("vega-statistics")):"function"==typeof define&&define.amd?define(["exports","vega-canvas","vega-dataflow","vega-util","vega-scale","vega-statistics"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).vega=t.vega||{},t.vega.transforms={}),t.vega,t.vega,t.vega,t.vega,t.vega)}(this,(function(t,e,n,r,a,i){"use strict";var o=Math.PI/180,f=2048;function s(){var t,n,r,a,i,o,s,g=[256,256],h=x,m=[],v=Math.random,p={};function z(t,e,n){for(var r,a,i,o,f,s=e.x,u=e.y,y=Math.sqrt(g[0]*g[0]+g[1]*g[1]),x=h(g),d=v()<.5?1:-1,c=-d;(r=x(c+=d))&&(a=~~r[0],i=~~r[1],!(Math.min(Math.abs(a),Math.abs(i))>=y));)if(e.x=s+a,e.y=u+i,!(e.x+e.x0<0||e.y+e.y0<0||e.x+e.x1>g[0]||e.y+e.y1>g[1]||n&&l(e,t,g[0])||n&&(f=n,!((o=e).x+o.x1>f[0].x&&o.x+o.x0<f[1].x&&o.y+o.y1>f[0].y&&o.y+o.y0<f[1].y)))){for(var m,p=e.sprite,z=e.width>>5,b=g[0]>>5,M=e.x-(z<<4),w=127&M,S=32-w,T=e.y1-e.y0,q=(e.y+e.y0)*b+(M>>5),W=0;W<T;W++){m=0;for(var k=0;k<=z;k++)t[q+k]|=m<<S|(k<z?(m=p[W*z+k])>>>w:0);q+=b}return e.sprite=null,!0}return!1}return p.layout=function(){for(var l=function(t){t.width=t.height=1;var e=Math.sqrt(t.getContext("2d").getImageData(0,0,1,1).data.length>>2);t.width=2048/e,t.height=f/e;var n=t.getContext("2d");return n.fillStyle=n.strokeStyle="red",n.textAlign="center",{context:n,ratio:e}}(e.canvas()),x=function(t){var e=[],n=-1;for(;++n<t;)e[n]=0;return e}((g[0]>>5)*g[1]),d=null,c=m.length,h=-1,p=[],b=m.map((function(e){return{text:t(e),font:n(e),style:a(e),weight:i(e),rotate:o(e),size:~~(r(e)+1e-14),padding:s(e),xoff:0,yoff:0,x1:0,y1:0,x0:0,y0:0,hasText:!1,sprite:null,datum:e}})).sort((function(t,e){return e.size-t.size}));++h<c;){var M=b[h];M.x=g[0]*(v()+.5)>>1,M.y=g[1]*(v()+.5)>>1,u(l,M,b,h),M.hasText&&z(x,M,d)&&(p.push(M),d?y(d,M):d=[{x:M.x+M.x0,y:M.y+M.y0},{x:M.x+M.x1,y:M.y+M.y1}],M.x-=g[0]>>1,M.y-=g[1]>>1)}return p},p.words=function(t){return arguments.length?(m=t,p):m},p.size=function(t){return arguments.length?(g=[+t[0],+t[1]],p):g},p.font=function(t){return arguments.length?(n=d(t),p):n},p.fontStyle=function(t){return arguments.length?(a=d(t),p):a},p.fontWeight=function(t){return arguments.length?(i=d(t),p):i},p.rotate=function(t){return arguments.length?(o=d(t),p):o},p.text=function(e){return arguments.length?(t=d(e),p):t},p.spiral=function(t){return arguments.length?(h=c[t]||t,p):h},p.fontSize=function(t){return arguments.length?(r=d(t),p):r},p.padding=function(t){return arguments.length?(s=d(t),p):s},p.random=function(t){return arguments.length?(v=t,p):v},p}function u(t,e,n,r){if(!e.sprite){var a=t.context,i=t.ratio;a.clearRect(0,0,2048/i,f/i);var s,u,l,y,x,d=0,c=0,g=0,h=n.length;for(--r;++r<h;){if(e=n[r],a.save(),a.font=e.style+" "+e.weight+" "+~~((e.size+1)/i)+"px "+e.font,s=a.measureText(e.text+"m").width*i,l=e.size<<1,e.rotate){var m=Math.sin(e.rotate*o),v=Math.cos(e.rotate*o),p=s*v,z=s*m,b=l*v,M=l*m;s=Math.max(Math.abs(p+M),Math.abs(p-M))+31>>5<<5,l=~~Math.max(Math.abs(z+b),Math.abs(z-b))}else s=s+31>>5<<5;if(l>g&&(g=l),d+s>=2048&&(d=0,c+=g,g=0),c+l>=f)break;a.translate((d+(s>>1))/i,(c+(l>>1))/i),e.rotate&&a.rotate(e.rotate*o),a.fillText(e.text,0,0),e.padding&&(a.lineWidth=2*e.padding,a.strokeText(e.text,0,0)),a.restore(),e.width=s,e.height=l,e.xoff=d,e.yoff=c,e.x1=s>>1,e.y1=l>>1,e.x0=-e.x1,e.y0=-e.y1,e.hasText=!0,d+=s}for(var w=a.getImageData(0,0,2048/i,f/i).data,S=[];--r>=0;)if((e=n[r]).hasText){for(u=(s=e.width)>>5,l=e.y1-e.y0,y=0;y<l*u;y++)S[y]=0;if(null==(d=e.xoff))return;c=e.yoff;var T=0,q=-1;for(x=0;x<l;x++){for(y=0;y<s;y++){var W=u*x+(y>>5),k=w[2048*(c+x)+(d+y)<<2]?1<<31-y%32:0;S[W]|=k,T|=k}T?q=x:(e.y0++,l--,x--,c++)}e.y1=e.y0+q,e.sprite=S.slice(0,(e.y1-e.y0)*u)}}}function l(t,e,n){n>>=5;for(var r,a=t.sprite,i=t.width>>5,o=t.x-(i<<4),f=127&o,s=32-f,u=t.y1-t.y0,l=(t.y+t.y0)*n+(o>>5),y=0;y<u;y++){r=0;for(var x=0;x<=i;x++)if((r<<s|(x<i?(r=a[y*i+x])>>>f:0))&e[l+x])return!0;l+=n}return!1}function y(t,e){var n=t[0],r=t[1];e.x+e.x0<n.x&&(n.x=e.x+e.x0),e.y+e.y0<n.y&&(n.y=e.y+e.y0),e.x+e.x1>r.x&&(r.x=e.x+e.x1),e.y+e.y1>r.y&&(r.y=e.y+e.y1)}function x(t){var e=t[0]/t[1];return function(t){return[e*(t*=.1)*Math.cos(t),t*Math.sin(t)]}}function d(t){return"function"==typeof t?t:function(){return t}}var c={archimedean:x,rectangular:function(t){var e=4*t[0]/t[1],n=0,r=0;return function(t){var a=t<0?-1:1;switch(Math.sqrt(1+4*a*t)-a&3){case 0:n+=e;break;case 1:r+=4;break;case 2:n-=e;break;default:r-=4}return[n,r]}}},g=["x","y","font","fontSize","fontStyle","fontWeight","angle"],h=["text","font","rotate","fontSize","fontStyle","fontWeight"];function m(t){n.Transform.call(this,s(),t)}m.Definition={type:"Wordcloud",metadata:{modifies:!0},params:[{name:"size",type:"number",array:!0,length:2},{name:"font",type:"string",expr:!0,default:"sans-serif"},{name:"fontStyle",type:"string",expr:!0,default:"normal"},{name:"fontWeight",type:"string",expr:!0,default:"normal"},{name:"fontSize",type:"number",expr:!0,default:14},{name:"fontSizeRange",type:"number",array:"nullable",default:[10,50]},{name:"rotate",type:"number",expr:!0,default:0},{name:"text",type:"field"},{name:"spiral",type:"string",values:["archimedean","rectangular"]},{name:"padding",type:"number",expr:!0},{name:"as",type:"string",array:!0,length:7,default:g}]},r.inherits(m,n.Transform,{transform(t,e){!t.size||t.size[0]&&t.size[1]||r.error("Wordcloud size dimensions must be non-zero.");const n=t.modified();if(!(n||e.changed(e.ADD_REM)||h.some((function(n){var a=t[n];return r.isFunction(a)&&e.modified(a.fields)}))))return;const o=e.materialize(e.SOURCE).source,f=this.value,s=t.as||g;let u,l=t.fontSize||14;if(r.isFunction(l)?u=t.fontSizeRange:l=r.constant(l),u){const t=l,e=a.scale("sqrt")().domain(r.extent(o,t)).range(u);l=n=>e(t(n))}o.forEach(t=>{t[s[0]]=NaN,t[s[1]]=NaN,t[s[3]]=0});const y=f.words(o).text(t.text).size(t.size||[500,500]).padding(t.padding||1).spiral(t.spiral||"archimedean").rotate(t.rotate||0).font(t.font||"sans-serif").fontStyle(t.fontStyle||"normal").fontWeight(t.fontWeight||"normal").fontSize(l).random(i.random).layout(),x=f.size(),d=x[0]>>1,c=x[1]>>1,m=y.length;for(let t,e,n=0;n<m;++n)t=y[n],e=t.datum,e[s[0]]=t.x+d,e[s[1]]=t.y+c,e[s[2]]=t.font,e[s[3]]=t.size,e[s[4]]=t.style,e[s[5]]=t.weight,e[s[6]]=t.rotate;return e.reflow(n).modifies(s)}}),t.wordcloud=m,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-util"),require("vega-scale"),require("vega-statistics")):"function"==typeof define&&define.amd?define(["exports","vega-canvas","vega-dataflow","vega-util","vega-scale","vega-statistics"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).vega=t.vega||{},t.vega.transforms={}),t.vega,t.vega,t.vega,t.vega,t.vega)}(this,(function(t,e,n,r,a,i){"use strict";var o=Math.PI/180,f=2048;function s(){var t,n,r,a,i,o,s,h=[256,256],c=x,m=[],v=Math.random,p={};function z(t,e,n){for(var r,a,i,o,f,s=e.x,u=e.y,y=Math.sqrt(h[0]*h[0]+h[1]*h[1]),x=c(h),d=v()<.5?1:-1,g=-d;(r=x(g+=d))&&(a=~~r[0],i=~~r[1],!(Math.min(Math.abs(a),Math.abs(i))>=y));)if(e.x=s+a,e.y=u+i,!(e.x+e.x0<0||e.y+e.y0<0||e.x+e.x1>h[0]||e.y+e.y1>h[1]||n&&l(e,t,h[0])||n&&(f=n,!((o=e).x+o.x1>f[0].x&&o.x+o.x0<f[1].x&&o.y+o.y1>f[0].y&&o.y+o.y0<f[1].y)))){for(var m,p=e.sprite,z=e.width>>5,b=h[0]>>5,M=e.x-(z<<4),w=127&M,S=32-w,T=e.y1-e.y0,q=(e.y+e.y0)*b+(M>>5),W=0;W<T;W++){m=0;for(var k=0;k<=z;k++)t[q+k]|=m<<S|(k<z?(m=p[W*z+k])>>>w:0);q+=b}return e.sprite=null,!0}return!1}return p.layout=function(){for(var l=function(t){t.width=t.height=1;var e=Math.sqrt(t.getContext("2d").getImageData(0,0,1,1).data.length>>2);t.width=2048/e,t.height=f/e;var n=t.getContext("2d");return n.fillStyle=n.strokeStyle="red",n.textAlign="center",{context:n,ratio:e}}(e.canvas()),x=function(t){var e=[],n=-1;for(;++n<t;)e[n]=0;return e}((h[0]>>5)*h[1]),d=null,g=m.length,c=-1,p=[],b=m.map(e=>({text:t(e),font:n(e),style:a(e),weight:i(e),rotate:o(e),size:~~(r(e)+1e-14),padding:s(e),xoff:0,yoff:0,x1:0,y1:0,x0:0,y0:0,hasText:!1,sprite:null,datum:e})).sort((t,e)=>e.size-t.size);++c<g;){var M=b[c];M.x=h[0]*(v()+.5)>>1,M.y=h[1]*(v()+.5)>>1,u(l,M,b,c),M.hasText&&z(x,M,d)&&(p.push(M),d?y(d,M):d=[{x:M.x+M.x0,y:M.y+M.y0},{x:M.x+M.x1,y:M.y+M.y1}],M.x-=h[0]>>1,M.y-=h[1]>>1)}return p},p.words=function(t){return arguments.length?(m=t,p):m},p.size=function(t){return arguments.length?(h=[+t[0],+t[1]],p):h},p.font=function(t){return arguments.length?(n=d(t),p):n},p.fontStyle=function(t){return arguments.length?(a=d(t),p):a},p.fontWeight=function(t){return arguments.length?(i=d(t),p):i},p.rotate=function(t){return arguments.length?(o=d(t),p):o},p.text=function(e){return arguments.length?(t=d(e),p):t},p.spiral=function(t){return arguments.length?(c=g[t]||t,p):c},p.fontSize=function(t){return arguments.length?(r=d(t),p):r},p.padding=function(t){return arguments.length?(s=d(t),p):s},p.random=function(t){return arguments.length?(v=t,p):v},p}function u(t,e,n,r){if(!e.sprite){var a=t.context,i=t.ratio;a.clearRect(0,0,2048/i,f/i);var s,u,l,y,x,d=0,g=0,h=0,c=n.length;for(--r;++r<c;){if(e=n[r],a.save(),a.font=e.style+" "+e.weight+" "+~~((e.size+1)/i)+"px "+e.font,s=a.measureText(e.text+"m").width*i,l=e.size<<1,e.rotate){var m=Math.sin(e.rotate*o),v=Math.cos(e.rotate*o),p=s*v,z=s*m,b=l*v,M=l*m;s=Math.max(Math.abs(p+M),Math.abs(p-M))+31>>5<<5,l=~~Math.max(Math.abs(z+b),Math.abs(z-b))}else s=s+31>>5<<5;if(l>h&&(h=l),d+s>=2048&&(d=0,g+=h,h=0),g+l>=f)break;a.translate((d+(s>>1))/i,(g+(l>>1))/i),e.rotate&&a.rotate(e.rotate*o),a.fillText(e.text,0,0),e.padding&&(a.lineWidth=2*e.padding,a.strokeText(e.text,0,0)),a.restore(),e.width=s,e.height=l,e.xoff=d,e.yoff=g,e.x1=s>>1,e.y1=l>>1,e.x0=-e.x1,e.y0=-e.y1,e.hasText=!0,d+=s}for(var w=a.getImageData(0,0,2048/i,f/i).data,S=[];--r>=0;)if((e=n[r]).hasText){for(u=(s=e.width)>>5,l=e.y1-e.y0,y=0;y<l*u;y++)S[y]=0;if(null==(d=e.xoff))return;g=e.yoff;var T=0,q=-1;for(x=0;x<l;x++){for(y=0;y<s;y++){var W=u*x+(y>>5),k=w[2048*(g+x)+(d+y)<<2]?1<<31-y%32:0;S[W]|=k,T|=k}T?q=x:(e.y0++,l--,x--,g++)}e.y1=e.y0+q,e.sprite=S.slice(0,(e.y1-e.y0)*u)}}}function l(t,e,n){n>>=5;for(var r,a=t.sprite,i=t.width>>5,o=t.x-(i<<4),f=127&o,s=32-f,u=t.y1-t.y0,l=(t.y+t.y0)*n+(o>>5),y=0;y<u;y++){r=0;for(var x=0;x<=i;x++)if((r<<s|(x<i?(r=a[y*i+x])>>>f:0))&e[l+x])return!0;l+=n}return!1}function y(t,e){var n=t[0],r=t[1];e.x+e.x0<n.x&&(n.x=e.x+e.x0),e.y+e.y0<n.y&&(n.y=e.y+e.y0),e.x+e.x1>r.x&&(r.x=e.x+e.x1),e.y+e.y1>r.y&&(r.y=e.y+e.y1)}function x(t){var e=t[0]/t[1];return function(t){return[e*(t*=.1)*Math.cos(t),t*Math.sin(t)]}}function d(t){return"function"==typeof t?t:function(){return t}}var g={archimedean:x,rectangular:function(t){var e=4*t[0]/t[1],n=0,r=0;return function(t){var a=t<0?-1:1;switch(Math.sqrt(1+4*a*t)-a&3){case 0:n+=e;break;case 1:r+=4;break;case 2:n-=e;break;default:r-=4}return[n,r]}}},h=["x","y","font","fontSize","fontStyle","fontWeight","angle"],c=["text","font","rotate","fontSize","fontStyle","fontWeight"];function m(t){n.Transform.call(this,s(),t)}m.Definition={type:"Wordcloud",metadata:{modifies:!0},params:[{name:"size",type:"number",array:!0,length:2},{name:"font",type:"string",expr:!0,default:"sans-serif"},{name:"fontStyle",type:"string",expr:!0,default:"normal"},{name:"fontWeight",type:"string",expr:!0,default:"normal"},{name:"fontSize",type:"number",expr:!0,default:14},{name:"fontSizeRange",type:"number",array:"nullable",default:[10,50]},{name:"rotate",type:"number",expr:!0,default:0},{name:"text",type:"field"},{name:"spiral",type:"string",values:["archimedean","rectangular"]},{name:"padding",type:"number",expr:!0},{name:"as",type:"string",array:!0,length:7,default:h}]},r.inherits(m,n.Transform,{transform(t,e){!t.size||t.size[0]&&t.size[1]||r.error("Wordcloud size dimensions must be non-zero.");const n=t.modified();if(!(n||e.changed(e.ADD_REM)||c.some((function(n){var a=t[n];return r.isFunction(a)&&e.modified(a.fields)}))))return;const o=e.materialize(e.SOURCE).source,f=this.value,s=t.as||h;let u,l=t.fontSize||14;if(r.isFunction(l)?u=t.fontSizeRange:l=r.constant(l),u){const t=l,e=a.scale("sqrt")().domain(r.extent(o,t)).range(u);l=n=>e(t(n))}o.forEach(t=>{t[s[0]]=NaN,t[s[1]]=NaN,t[s[3]]=0});const y=f.words(o).text(t.text).size(t.size||[500,500]).padding(t.padding||1).spiral(t.spiral||"archimedean").rotate(t.rotate||0).font(t.font||"sans-serif").fontStyle(t.fontStyle||"normal").fontWeight(t.fontWeight||"normal").fontSize(l).random(i.random).layout(),x=f.size(),d=x[0]>>1,g=x[1]>>1,m=y.length;for(let t,e,n=0;n<m;++n)t=y[n],e=t.datum,e[s[0]]=t.x+d,e[s[1]]=t.y+g,e[s[2]]=t.font,e[s[3]]=t.size,e[s[4]]=t.style,e[s[5]]=t.weight,e[s[6]]=t.rotate;return e.reflow(n).modifies(s)}}),t.wordcloud=m,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "vega-wordcloud",
"version": "4.1.1",
"version": "4.1.2",
"description": "Wordcloud layout transform for Vega dataflows.",

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

"dependencies": {
"vega-canvas": "^1.2.3",
"vega-dataflow": "^5.7.1",
"vega-scale": "^7.0.1",
"vega-statistics": "^1.7.7",
"vega-util": "^1.15.0"
"vega-canvas": "^1.2.4",
"vega-dataflow": "^5.7.2",
"vega-scale": "^7.1.0",
"vega-statistics": "^1.7.8",
"vega-util": "^1.15.1"
},

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

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

@@ -60,22 +60,20 @@ import {canvas} from 'vega-canvas';

tags = [],
data = words.map(function(d) {
return {
text: text(d),
font: font(d),
style: fontStyle(d),
weight: fontWeight(d),
rotate: rotate(d),
size: ~~(fontSize(d) + 1e-14),
padding: padding(d),
xoff: 0,
yoff: 0,
x1: 0,
y1: 0,
x0: 0,
y0: 0,
hasText: false,
sprite: null,
datum: d
};
}).sort(function(a, b) { return b.size - a.size; });
data = words.map(d => ({
text: text(d),
font: font(d),
style: fontStyle(d),
weight: fontWeight(d),
rotate: rotate(d),
size: ~~(fontSize(d) + 1e-14),
padding: padding(d),
xoff: 0,
yoff: 0,
x1: 0,
y1: 0,
x0: 0,
y0: 0,
hasText: false,
sprite: null,
datum: d
})).sort((a, b) => b.size - a.size);

@@ -82,0 +80,0 @@ while (++i < n) {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc