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 1.0.0-beta.1 to 1.0.0-beta.2

5

build/vega-wordcloud.js

@@ -399,3 +399,4 @@ (function (global, factory) {

prototype.transform = function(_, pulse) {
var run = _.modified()
var mod = _.modified(),
run = mod
|| pulse.changed(pulse.ADD_REM)

@@ -466,3 +467,3 @@ || vegaUtil.isFunction(_.text) && pulse.modified(_.text.fields)

return pulse.reflow().modifies(as);
return pulse.reflow(mod).modifies(as);
};

@@ -469,0 +470,0 @@

2

build/vega-wordcloud.min.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-dataflow"),require("vega-util"),require("vega-scale")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","vega-scale"],e):e(t.vega=t.vega||{},t.vega,t.vega,t.vega)}(this,function(t,e,n,r){"use strict";function a(t,e,n,r){if(!e.sprite){var a=t.context,i=t.ratio;a.clearRect(0,0,(g<<5)/i,m/i);var o,f,u,s,l,y=0,d=0,c=0,x=n.length;for(--r;++r<x;){if(e=n[r],a.save(),a.font=e.style+" "+e.weight+" "+~~((e.size+1)/i)+"px "+e.font,o=a.measureText(e.text+"m").width*i,u=e.size<<1,e.rotate){var v=Math.sin(e.rotate*h),p=Math.cos(e.rotate*h),z=o*p,S=o*v,M=u*p,b=u*v;o=Math.max(Math.abs(z+b),Math.abs(z-b))+31>>5<<5,u=~~Math.max(Math.abs(S+M),Math.abs(S-M))}else o=o+31>>5<<5;if(u>c&&(c=u),y+o>=g<<5&&(y=0,d+=c,c=0),d+u>=m)break;a.translate((y+(o>>1))/i,(d+(u>>1))/i),e.rotate&&a.rotate(e.rotate*h),a.fillText(e.text,0,0),e.padding&&(a.lineWidth=2*e.padding,a.strokeText(e.text,0,0)),a.restore(),e.width=o,e.height=u,e.xoff=y,e.yoff=d,e.x1=o>>1,e.y1=u>>1,e.x0=-e.x1,e.y0=-e.y1,e.hasText=!0,y+=o}for(var w=a.getImageData(0,0,(g<<5)/i,m/i).data,W=[];--r>=0;)if(e=n[r],e.hasText){for(o=e.width,f=o>>5,u=e.y1-e.y0,s=0;s<u*f;s++)W[s]=0;if(y=e.xoff,null==y)return;d=e.yoff;var T=0,q=-1;for(l=0;l<u;l++){for(s=0;s<o;s++){var F=f*l+(s>>5),k=w[(d+l)*(g<<5)+(y+s)<<2]?1<<31-s%32:0;W[F]|=k,T|=k}T?q=l:(e.y0++,u--,l--,d++)}e.y1=e.y0+q,e.sprite=W.slice(0,(e.y1-e.y0)*f)}}}function i(t,e,n){n>>=5;for(var r,a=t.sprite,i=t.width>>5,o=t.x-(i<<4),f=127&o,u=32-f,s=t.y1-t.y0,l=(t.y+t.y0)*n+(o>>5),y=0;y<s;y++){r=0;for(var d=0;d<=i;d++)if((r<<u|(d<i?(r=a[y*i+d])>>>f:0))&e[l+d])return!0;l+=n}return!1}function o(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 f(t,e){return t.x+t.x1>e[0].x&&t.x+t.x0<e[1].x&&t.y+t.y1>e[0].y&&t.y+t.y0<e[1].y}function u(t){var e=t[0]/t[1];return function(t){return[e*(t*=.1)*Math.cos(t),t*Math.sin(t)]}}function s(t){var e=4,n=e*t[0]/t[1],r=0,a=0;return function(t){var i=t<0?-1:1;switch(Math.sqrt(1+4*i*t)-i&3){case 0:r+=n;break;case 1:a+=e;break;case 2:r-=n;break;default:a-=e}return[r,a]}}function l(t){for(var e=[],n=-1;++n<t;)e[n]=0;return e}function y(){try{return"undefined"!=typeof document&&document.createElement?document.createElement("canvas"):new(require("canvas"))}catch(t){n.error("Canvas unavailable. Run in browser or install node-canvas.")}}function d(t){return"function"==typeof t?t:function(){return t}}function c(t){e.Transform.call(this,v(),t)}function x(t,r){var a=new e.transforms.Extent;return a.transform({field:t,modified:n.truthy},r),a.value}var h=Math.PI/180,g=64,m=2048,v=function(){function t(t){t.width=t.height=1;var e=Math.sqrt(t.getContext("2d").getImageData(0,0,1,1).data.length>>2);t.width=(g<<5)/e,t.height=m/e;var n=t.getContext("2d");return n.fillStyle=n.strokeStyle="red",n.textAlign="center",{context:n,ratio:e}}function e(t,e,n){for(var r,a,o,u=e.x,s=e.y,l=Math.sqrt(z[0]*z[0]+z[1]*z[1]),y=S(z),d=b()<.5?1:-1,c=-d;(r=y(c+=d))&&(a=~~r[0],o=~~r[1],!(Math.min(Math.abs(a),Math.abs(o))>=l));)if(e.x=u+a,e.y=s+o,!(e.x+e.x0<0||e.y+e.y0<0||e.x+e.x1>z[0]||e.y+e.y1>z[1])&&(!n||!i(e,t,z[0]))&&(!n||f(e,n))){for(var x,h=e.sprite,g=e.width>>5,m=z[0]>>5,v=e.x-(g<<4),p=127&v,M=32-p,w=e.y1-e.y0,W=(e.y+e.y0)*m+(v>>5),T=0;T<w;T++){x=0;for(var q=0;q<=g;q++)t[W+q]|=x<<M|(q<g?(x=h[T*g+q])>>>p:0);W+=m}return e.sprite=null,!0}return!1}var n,r,s,c,x,h,v,z=[256,256],S=u,M=[],b=Math.random,w={},W=y;return w.layout=function(){for(var i=t(W()),f=l((z[0]>>5)*z[1]),u=null,y=M.length,d=-1,g=[],m=M.map(function(t){return{text:n(t),font:r(t),style:c(t),weight:x(t),rotate:h(t),size:~~s(t),padding:v(t),xoff:0,yoff:0,x1:0,y1:0,x0:0,y0:0,hasText:!1,sprite:null,datum:t}}).sort(function(t,e){return e.size-t.size});++d<y;){var p=m[d];p.x=z[0]*(b()+.5)>>1,p.y=z[1]*(b()+.5)>>1,a(i,p,m,d),p.hasText&&e(f,p,u)&&(g.push(p),u?o(u,p):u=[{x:p.x+p.x0,y:p.y+p.y0},{x:p.x+p.x1,y:p.y+p.y1}],p.x-=z[0]>>1,p.y-=z[1]>>1)}return g},w.words=function(t){return arguments.length?(M=t,w):M},w.size=function(t){return arguments.length?(z=[+t[0],+t[1]],w):z},w.font=function(t){return arguments.length?(r=d(t),w):r},w.fontStyle=function(t){return arguments.length?(c=d(t),w):c},w.fontWeight=function(t){return arguments.length?(x=d(t),w):x},w.rotate=function(t){return arguments.length?(h=d(t),w):h},w.text=function(t){return arguments.length?(n=d(t),w):n},w.spiral=function(t){return arguments.length?(S=p[t]||t,w):S},w.fontSize=function(t){return arguments.length?(s=d(t),w):s},w.padding=function(t){return arguments.length?(v=d(t),w):v},w.random=function(t){return arguments.length?(b=t,w):b},w},p={archimedean:u,rectangular:s},z=["x","y","font","fontSize","fontStyle","fontWeight","angle"],S=n.inherits(c,e.Transform);S.transform=function(t,e){var a=t.modified()||e.changed(e.ADD_REM)||n.isFunction(t.text)&&e.modified(t.text.fields)||n.isFunction(t.font)&&e.modified(t.font.fields)||n.isFunction(t.rotate)&&e.modified(t.rotate.fields)||n.isFunction(t.fontSize)&&e.modified(t.fontSize.fields)||n.isFunction(t.fontStyle)&&e.modified(t.fontStyle.fields)||n.isFunction(t.fontWeight)&&e.modified(t.fontWeight.fields);if(a){var i,o,f,u,s=this.value,l=t.as||z,y=t.fontSize||14;n.isFunction(y)?i=t.fontSizeRange:y=n.constant(y),i&&(o=y,f=r.scale("sqrt")().domain(x(o,e)).range(i),y=function(t){return f(o(t))});var d=e.materialize(e.SOURCE).source;d.forEach(function(t){t[l[0]]=NaN,t[l[1]]=NaN,t[l[3]]=0}),u=s.words(d).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(y).layout();for(var c,h,g=s.size(),m=g[0]>>1,v=g[1]>>1,p=0,S=u.length;p<S;++p)c=u[p],h=c.datum,h[l[0]]=c.x+m,h[l[1]]=c.y+v,h[l[2]]=c.font,h[l[3]]=c.size,h[l[4]]=c.style,h[l[5]]=c.weight,h[l[6]]=c.rotate;return e.reflow().modifies(l)}};var M={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:!0,null:!0,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:["x","y","font","fontSize","fontStyle","fontWeight","angle"]}]};e.register(M,c),t.transform=e.transform,t.definition=e.definition,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-dataflow"),require("vega-util"),require("vega-scale")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","vega-scale"],e):e(t.vega=t.vega||{},t.vega,t.vega,t.vega)}(this,function(t,e,n,r){"use strict";function a(t,e,n,r){if(!e.sprite){var a=t.context,i=t.ratio;a.clearRect(0,0,(g<<5)/i,m/i);var o,f,u,s,l,y=0,d=0,c=0,x=n.length;for(--r;++r<x;){if(e=n[r],a.save(),a.font=e.style+" "+e.weight+" "+~~((e.size+1)/i)+"px "+e.font,o=a.measureText(e.text+"m").width*i,u=e.size<<1,e.rotate){var v=Math.sin(e.rotate*h),p=Math.cos(e.rotate*h),z=o*p,S=o*v,M=u*p,b=u*v;o=Math.max(Math.abs(z+b),Math.abs(z-b))+31>>5<<5,u=~~Math.max(Math.abs(S+M),Math.abs(S-M))}else o=o+31>>5<<5;if(u>c&&(c=u),y+o>=g<<5&&(y=0,d+=c,c=0),d+u>=m)break;a.translate((y+(o>>1))/i,(d+(u>>1))/i),e.rotate&&a.rotate(e.rotate*h),a.fillText(e.text,0,0),e.padding&&(a.lineWidth=2*e.padding,a.strokeText(e.text,0,0)),a.restore(),e.width=o,e.height=u,e.xoff=y,e.yoff=d,e.x1=o>>1,e.y1=u>>1,e.x0=-e.x1,e.y0=-e.y1,e.hasText=!0,y+=o}for(var w=a.getImageData(0,0,(g<<5)/i,m/i).data,W=[];--r>=0;)if(e=n[r],e.hasText){for(o=e.width,f=o>>5,u=e.y1-e.y0,s=0;s<u*f;s++)W[s]=0;if(y=e.xoff,null==y)return;d=e.yoff;var T=0,q=-1;for(l=0;l<u;l++){for(s=0;s<o;s++){var F=f*l+(s>>5),k=w[(d+l)*(g<<5)+(y+s)<<2]?1<<31-s%32:0;W[F]|=k,T|=k}T?q=l:(e.y0++,u--,l--,d++)}e.y1=e.y0+q,e.sprite=W.slice(0,(e.y1-e.y0)*f)}}}function i(t,e,n){n>>=5;for(var r,a=t.sprite,i=t.width>>5,o=t.x-(i<<4),f=127&o,u=32-f,s=t.y1-t.y0,l=(t.y+t.y0)*n+(o>>5),y=0;y<s;y++){r=0;for(var d=0;d<=i;d++)if((r<<u|(d<i?(r=a[y*i+d])>>>f:0))&e[l+d])return!0;l+=n}return!1}function o(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 f(t,e){return t.x+t.x1>e[0].x&&t.x+t.x0<e[1].x&&t.y+t.y1>e[0].y&&t.y+t.y0<e[1].y}function u(t){var e=t[0]/t[1];return function(t){return[e*(t*=.1)*Math.cos(t),t*Math.sin(t)]}}function s(t){var e=4,n=e*t[0]/t[1],r=0,a=0;return function(t){var i=t<0?-1:1;switch(Math.sqrt(1+4*i*t)-i&3){case 0:r+=n;break;case 1:a+=e;break;case 2:r-=n;break;default:a-=e}return[r,a]}}function l(t){for(var e=[],n=-1;++n<t;)e[n]=0;return e}function y(){try{return"undefined"!=typeof document&&document.createElement?document.createElement("canvas"):new(require("canvas"))}catch(t){n.error("Canvas unavailable. Run in browser or install node-canvas.")}}function d(t){return"function"==typeof t?t:function(){return t}}function c(t){e.Transform.call(this,v(),t)}function x(t,r){var a=new e.transforms.Extent;return a.transform({field:t,modified:n.truthy},r),a.value}var h=Math.PI/180,g=64,m=2048,v=function(){function t(t){t.width=t.height=1;var e=Math.sqrt(t.getContext("2d").getImageData(0,0,1,1).data.length>>2);t.width=(g<<5)/e,t.height=m/e;var n=t.getContext("2d");return n.fillStyle=n.strokeStyle="red",n.textAlign="center",{context:n,ratio:e}}function e(t,e,n){for(var r,a,o,u=e.x,s=e.y,l=Math.sqrt(z[0]*z[0]+z[1]*z[1]),y=S(z),d=b()<.5?1:-1,c=-d;(r=y(c+=d))&&(a=~~r[0],o=~~r[1],!(Math.min(Math.abs(a),Math.abs(o))>=l));)if(e.x=u+a,e.y=s+o,!(e.x+e.x0<0||e.y+e.y0<0||e.x+e.x1>z[0]||e.y+e.y1>z[1])&&(!n||!i(e,t,z[0]))&&(!n||f(e,n))){for(var x,h=e.sprite,g=e.width>>5,m=z[0]>>5,v=e.x-(g<<4),p=127&v,M=32-p,w=e.y1-e.y0,W=(e.y+e.y0)*m+(v>>5),T=0;T<w;T++){x=0;for(var q=0;q<=g;q++)t[W+q]|=x<<M|(q<g?(x=h[T*g+q])>>>p:0);W+=m}return e.sprite=null,!0}return!1}var n,r,s,c,x,h,v,z=[256,256],S=u,M=[],b=Math.random,w={},W=y;return w.layout=function(){for(var i=t(W()),f=l((z[0]>>5)*z[1]),u=null,y=M.length,d=-1,g=[],m=M.map(function(t){return{text:n(t),font:r(t),style:c(t),weight:x(t),rotate:h(t),size:~~s(t),padding:v(t),xoff:0,yoff:0,x1:0,y1:0,x0:0,y0:0,hasText:!1,sprite:null,datum:t}}).sort(function(t,e){return e.size-t.size});++d<y;){var p=m[d];p.x=z[0]*(b()+.5)>>1,p.y=z[1]*(b()+.5)>>1,a(i,p,m,d),p.hasText&&e(f,p,u)&&(g.push(p),u?o(u,p):u=[{x:p.x+p.x0,y:p.y+p.y0},{x:p.x+p.x1,y:p.y+p.y1}],p.x-=z[0]>>1,p.y-=z[1]>>1)}return g},w.words=function(t){return arguments.length?(M=t,w):M},w.size=function(t){return arguments.length?(z=[+t[0],+t[1]],w):z},w.font=function(t){return arguments.length?(r=d(t),w):r},w.fontStyle=function(t){return arguments.length?(c=d(t),w):c},w.fontWeight=function(t){return arguments.length?(x=d(t),w):x},w.rotate=function(t){return arguments.length?(h=d(t),w):h},w.text=function(t){return arguments.length?(n=d(t),w):n},w.spiral=function(t){return arguments.length?(S=p[t]||t,w):S},w.fontSize=function(t){return arguments.length?(s=d(t),w):s},w.padding=function(t){return arguments.length?(v=d(t),w):v},w.random=function(t){return arguments.length?(b=t,w):b},w},p={archimedean:u,rectangular:s},z=["x","y","font","fontSize","fontStyle","fontWeight","angle"],S=n.inherits(c,e.Transform);S.transform=function(t,e){var a=t.modified(),i=a||e.changed(e.ADD_REM)||n.isFunction(t.text)&&e.modified(t.text.fields)||n.isFunction(t.font)&&e.modified(t.font.fields)||n.isFunction(t.rotate)&&e.modified(t.rotate.fields)||n.isFunction(t.fontSize)&&e.modified(t.fontSize.fields)||n.isFunction(t.fontStyle)&&e.modified(t.fontStyle.fields)||n.isFunction(t.fontWeight)&&e.modified(t.fontWeight.fields);if(i){var o,f,u,s,l=this.value,y=t.as||z,d=t.fontSize||14;n.isFunction(d)?o=t.fontSizeRange:d=n.constant(d),o&&(f=d,u=r.scale("sqrt")().domain(x(f,e)).range(o),d=function(t){return u(f(t))});var c=e.materialize(e.SOURCE).source;c.forEach(function(t){t[y[0]]=NaN,t[y[1]]=NaN,t[y[3]]=0}),s=l.words(c).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(d).layout();for(var h,g,m=l.size(),v=m[0]>>1,p=m[1]>>1,S=0,M=s.length;S<M;++S)h=s[S],g=h.datum,g[y[0]]=h.x+v,g[y[1]]=h.y+p,g[y[2]]=h.font,g[y[3]]=h.size,g[y[4]]=h.style,g[y[5]]=h.weight,g[y[6]]=h.rotate;return e.reflow(a).modifies(y)}};var M={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:!0,null:!0,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:["x","y","font","fontSize","fontStyle","fontWeight","angle"]}]};e.register(M,c),t.transform=e.transform,t.definition=e.definition,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "vega-wordcloud",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "Wordcloud layout transform for Vega dataflows.",

@@ -30,3 +30,3 @@ "keywords": [

"dependencies": {
"vega-dataflow": ">=2.0.0-beta",
"vega-dataflow": ">=2.0.0-beta.4",
"vega-scale": "1",

@@ -33,0 +33,0 @@ "vega-util": "1"

@@ -15,3 +15,4 @@ import cloud from './CloudLayout';

prototype.transform = function(_, pulse) {
var run = _.modified()
var mod = _.modified(),
run = mod
|| pulse.changed(pulse.ADD_REM)

@@ -82,3 +83,3 @@ || isFunction(_.text) && pulse.modified(_.text.fields)

return pulse.reflow().modifies(as);
return pulse.reflow(mod).modifies(as);
};

@@ -85,0 +86,0 @@

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