vega-wordcloud
Advanced tools
Comparing version 4.0.3 to 4.0.4
@@ -71,3 +71,3 @@ (function (global, factory) { | ||
rotate: rotate(d), | ||
size: ~~fontSize(d), | ||
size: ~~(fontSize(d) + 1e-14), | ||
padding: padding(d), | ||
@@ -74,0 +74,0 @@ xoff: 0, |
@@ -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=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=64,s=2048;function u(){var t,n,r,a,i,o,u,h=[256,256],m=d,v=[],p=Math.random,z={};function M(t,e,n){for(var r,a,i,o,f,s=e.x,u=e.y,l=Math.sqrt(h[0]*h[0]+h[1]*h[1]),x=m(h),d=p()<.5?1:-1,c=-d;(r=x(c+=d))&&(a=~~r[0],i=~~r[1],!(Math.min(Math.abs(a),Math.abs(i))>=l));)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&&y(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 g,v=e.sprite,z=e.width>>5,M=h[0]>>5,b=e.x-(z<<4),w=127&b,S=32-w,q=e.y1-e.y0,T=(e.y+e.y0)*M+(b>>5),W=0;W<q;W++){g=0;for(var k=0;k<=z;k++)t[T+k]|=g<<S|(k<z?(g=v[W*z+k])>>>w:0);T+=M}return e.sprite=null,!0}return!1}return z.layout=function(){for(var y=function(t){t.width=t.height=1;var e=Math.sqrt(t.getContext("2d").getImageData(0,0,1,1).data.length>>2);t.width=(f<<5)/e,t.height=s/e;var n=t.getContext("2d");return n.fillStyle=n.strokeStyle="red",n.textAlign="center",{context:n,ratio:e}}(e.canvas()),d=function(t){var e=[],n=-1;for(;++n<t;)e[n]=0;return e}((h[0]>>5)*h[1]),c=null,g=v.length,m=-1,z=[],b=v.map((function(e){return{text:t(e),font:n(e),style:a(e),weight:i(e),rotate:o(e),size:~~r(e),padding:u(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}));++m<g;){var w=b[m];w.x=h[0]*(p()+.5)>>1,w.y=h[1]*(p()+.5)>>1,l(y,w,b,m),w.hasText&&M(d,w,c)&&(z.push(w),c?x(c,w):c=[{x:w.x+w.x0,y:w.y+w.y0},{x:w.x+w.x1,y:w.y+w.y1}],w.x-=h[0]>>1,w.y-=h[1]>>1)}return z},z.words=function(t){return arguments.length?(v=t,z):v},z.size=function(t){return arguments.length?(h=[+t[0],+t[1]],z):h},z.font=function(t){return arguments.length?(n=c(t),z):n},z.fontStyle=function(t){return arguments.length?(a=c(t),z):a},z.fontWeight=function(t){return arguments.length?(i=c(t),z):i},z.rotate=function(t){return arguments.length?(o=c(t),z):o},z.text=function(e){return arguments.length?(t=c(e),z):t},z.spiral=function(t){return arguments.length?(m=g[t]||t,z):m},z.fontSize=function(t){return arguments.length?(r=c(t),z):r},z.padding=function(t){return arguments.length?(u=c(t),z):u},z.random=function(t){return arguments.length?(p=t,z):p},z}function l(t,e,n,r){if(!e.sprite){var a=t.context,i=t.ratio;a.clearRect(0,0,(f<<5)/i,s/i);var u,l,y,x,d,c=0,g=0,h=0,m=n.length;for(--r;++r<m;){if(e=n[r],a.save(),a.font=e.style+" "+e.weight+" "+~~((e.size+1)/i)+"px "+e.font,u=a.measureText(e.text+"m").width*i,y=e.size<<1,e.rotate){var v=Math.sin(e.rotate*o),p=Math.cos(e.rotate*o),z=u*p,M=u*v,b=y*p,w=y*v;u=Math.max(Math.abs(z+w),Math.abs(z-w))+31>>5<<5,y=~~Math.max(Math.abs(M+b),Math.abs(M-b))}else u=u+31>>5<<5;if(y>h&&(h=y),c+u>=f<<5&&(c=0,g+=h,h=0),g+y>=s)break;a.translate((c+(u>>1))/i,(g+(y>>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=u,e.height=y,e.xoff=c,e.yoff=g,e.x1=u>>1,e.y1=y>>1,e.x0=-e.x1,e.y0=-e.y1,e.hasText=!0,c+=u}for(var S=a.getImageData(0,0,(f<<5)/i,s/i).data,q=[];--r>=0;)if((e=n[r]).hasText){for(l=(u=e.width)>>5,y=e.y1-e.y0,x=0;x<y*l;x++)q[x]=0;if(null==(c=e.xoff))return;g=e.yoff;var T=0,W=-1;for(d=0;d<y;d++){for(x=0;x<u;x++){var k=l*d+(x>>5),D=S[(g+d)*(f<<5)+(c+x)<<2]?1<<31-x%32:0;q[k]|=D,T|=D}T?W=d:(e.y0++,y--,d--,g++)}e.y1=e.y0+W,e.sprite=q.slice(0,(e.y1-e.y0)*l)}}}function y(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 x(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 d(t){var e=t[0]/t[1];return function(t){return[e*(t*=.1)*Math.cos(t),t*Math.sin(t)]}}function c(t){return"function"==typeof t?t:function(){return t}}var g={archimedean:d,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"],m=["text","font","rotate","fontSize","fontStyle","fontWeight"];function v(t){n.Transform.call(this,u(),t)}v.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(v,n.Transform).transform=function(t,e){!t.size||t.size[0]&&t.size[1]||r.error("Wordcloud size dimensions must be non-zero.");var n=t.modified();if(n||e.changed(e.ADD_REM)||m.some((function(n){var a=t[n];return r.isFunction(a)&&e.modified(a.fields)}))){var o,f=e.materialize(e.SOURCE).source,s=this.value,u=t.as||h,l=t.fontSize||14;if(r.isFunction(l)?o=t.fontSizeRange:l=r.constant(l),o){var y=l,x=a.scale("sqrt")().domain(r.extent(f,y)).range(o);l=function(t){return x(y(t))}}f.forEach((function(t){t[u[0]]=NaN,t[u[1]]=NaN,t[u[3]]=0}));for(var d,c,g=s.words(f).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(),v=s.size(),p=v[0]>>1,z=v[1]>>1,M=0,b=g.length;M<b;++M)(c=(d=g[M]).datum)[u[0]]=d.x+p,c[u[1]]=d.y+z,c[u[2]]=d.font,c[u[3]]=d.size,c[u[4]]=d.style,c[u[5]]=d.weight,c[u[6]]=d.rotate;return e.reflow(n).modifies(u)}},t.wordcloud=v,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=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=64,s=2048;function u(){var t,n,r,a,i,o,u,h=[256,256],m=d,v=[],p=Math.random,z={};function M(t,e,n){for(var r,a,i,o,f,s=e.x,u=e.y,l=Math.sqrt(h[0]*h[0]+h[1]*h[1]),x=m(h),d=p()<.5?1:-1,c=-d;(r=x(c+=d))&&(a=~~r[0],i=~~r[1],!(Math.min(Math.abs(a),Math.abs(i))>=l));)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&&y(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 g,v=e.sprite,z=e.width>>5,M=h[0]>>5,b=e.x-(z<<4),w=127&b,S=32-w,q=e.y1-e.y0,T=(e.y+e.y0)*M+(b>>5),W=0;W<q;W++){g=0;for(var k=0;k<=z;k++)t[T+k]|=g<<S|(k<z?(g=v[W*z+k])>>>w:0);T+=M}return e.sprite=null,!0}return!1}return z.layout=function(){for(var y=function(t){t.width=t.height=1;var e=Math.sqrt(t.getContext("2d").getImageData(0,0,1,1).data.length>>2);t.width=(f<<5)/e,t.height=s/e;var n=t.getContext("2d");return n.fillStyle=n.strokeStyle="red",n.textAlign="center",{context:n,ratio:e}}(e.canvas()),d=function(t){var e=[],n=-1;for(;++n<t;)e[n]=0;return e}((h[0]>>5)*h[1]),c=null,g=v.length,m=-1,z=[],b=v.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:u(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}));++m<g;){var w=b[m];w.x=h[0]*(p()+.5)>>1,w.y=h[1]*(p()+.5)>>1,l(y,w,b,m),w.hasText&&M(d,w,c)&&(z.push(w),c?x(c,w):c=[{x:w.x+w.x0,y:w.y+w.y0},{x:w.x+w.x1,y:w.y+w.y1}],w.x-=h[0]>>1,w.y-=h[1]>>1)}return z},z.words=function(t){return arguments.length?(v=t,z):v},z.size=function(t){return arguments.length?(h=[+t[0],+t[1]],z):h},z.font=function(t){return arguments.length?(n=c(t),z):n},z.fontStyle=function(t){return arguments.length?(a=c(t),z):a},z.fontWeight=function(t){return arguments.length?(i=c(t),z):i},z.rotate=function(t){return arguments.length?(o=c(t),z):o},z.text=function(e){return arguments.length?(t=c(e),z):t},z.spiral=function(t){return arguments.length?(m=g[t]||t,z):m},z.fontSize=function(t){return arguments.length?(r=c(t),z):r},z.padding=function(t){return arguments.length?(u=c(t),z):u},z.random=function(t){return arguments.length?(p=t,z):p},z}function l(t,e,n,r){if(!e.sprite){var a=t.context,i=t.ratio;a.clearRect(0,0,(f<<5)/i,s/i);var u,l,y,x,d,c=0,g=0,h=0,m=n.length;for(--r;++r<m;){if(e=n[r],a.save(),a.font=e.style+" "+e.weight+" "+~~((e.size+1)/i)+"px "+e.font,u=a.measureText(e.text+"m").width*i,y=e.size<<1,e.rotate){var v=Math.sin(e.rotate*o),p=Math.cos(e.rotate*o),z=u*p,M=u*v,b=y*p,w=y*v;u=Math.max(Math.abs(z+w),Math.abs(z-w))+31>>5<<5,y=~~Math.max(Math.abs(M+b),Math.abs(M-b))}else u=u+31>>5<<5;if(y>h&&(h=y),c+u>=f<<5&&(c=0,g+=h,h=0),g+y>=s)break;a.translate((c+(u>>1))/i,(g+(y>>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=u,e.height=y,e.xoff=c,e.yoff=g,e.x1=u>>1,e.y1=y>>1,e.x0=-e.x1,e.y0=-e.y1,e.hasText=!0,c+=u}for(var S=a.getImageData(0,0,(f<<5)/i,s/i).data,q=[];--r>=0;)if((e=n[r]).hasText){for(l=(u=e.width)>>5,y=e.y1-e.y0,x=0;x<y*l;x++)q[x]=0;if(null==(c=e.xoff))return;g=e.yoff;var T=0,W=-1;for(d=0;d<y;d++){for(x=0;x<u;x++){var k=l*d+(x>>5),D=S[(g+d)*(f<<5)+(c+x)<<2]?1<<31-x%32:0;q[k]|=D,T|=D}T?W=d:(e.y0++,y--,d--,g++)}e.y1=e.y0+W,e.sprite=q.slice(0,(e.y1-e.y0)*l)}}}function y(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 x(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 d(t){var e=t[0]/t[1];return function(t){return[e*(t*=.1)*Math.cos(t),t*Math.sin(t)]}}function c(t){return"function"==typeof t?t:function(){return t}}var g={archimedean:d,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"],m=["text","font","rotate","fontSize","fontStyle","fontWeight"];function v(t){n.Transform.call(this,u(),t)}v.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(v,n.Transform).transform=function(t,e){!t.size||t.size[0]&&t.size[1]||r.error("Wordcloud size dimensions must be non-zero.");var n=t.modified();if(n||e.changed(e.ADD_REM)||m.some((function(n){var a=t[n];return r.isFunction(a)&&e.modified(a.fields)}))){var o,f=e.materialize(e.SOURCE).source,s=this.value,u=t.as||h,l=t.fontSize||14;if(r.isFunction(l)?o=t.fontSizeRange:l=r.constant(l),o){var y=l,x=a.scale("sqrt")().domain(r.extent(f,y)).range(o);l=function(t){return x(y(t))}}f.forEach((function(t){t[u[0]]=NaN,t[u[1]]=NaN,t[u[3]]=0}));for(var d,c,g=s.words(f).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(),v=s.size(),p=v[0]>>1,z=v[1]>>1,M=0,b=g.length;M<b;++M)(c=(d=g[M]).datum)[u[0]]=d.x+p,c[u[1]]=d.y+z,c[u[2]]=d.font,c[u[3]]=d.size,c[u[4]]=d.style,c[u[5]]=d.weight,c[u[6]]=d.rotate;return e.reflow(n).modifies(u)}},t.wordcloud=v,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "vega-wordcloud", | ||
"version": "4.0.3", | ||
"version": "4.0.4", | ||
"description": "Wordcloud layout transform for Vega dataflows.", | ||
@@ -28,5 +28,5 @@ "keywords": [ | ||
"vega-dataflow": "^5.4.1", | ||
"vega-scale": "^5.0.0", | ||
"vega-statistics": "^1.6.2", | ||
"vega-util": "^1.12.0" | ||
"vega-scale": "^6.0.0", | ||
"vega-statistics": "^1.7.1", | ||
"vega-util": "^1.12.1" | ||
}, | ||
@@ -36,3 +36,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "8180e8ca9379dec7f1722ce0ebd2aa01083be7b2" | ||
"gitHead": "b690910bacfcb2580511e262400e496d9b14b04f" | ||
} |
@@ -67,3 +67,3 @@ import {canvas} from 'vega-canvas'; | ||
rotate: rotate(d), | ||
size: ~~fontSize(d), | ||
size: ~~(fontSize(d) + 1e-14), | ||
padding: padding(d), | ||
@@ -70,0 +70,0 @@ xoff: 0, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39492
+ Addedd3-format@1.4.5(transitive)
+ Addedd3-time@1.1.0(transitive)
+ Addedd3-time-format@2.3.0(transitive)
+ Addedvega-scale@6.1.0(transitive)
+ Addedvega-time@1.1.0(transitive)
- Removedvega-scale@5.0.0(transitive)
Updatedvega-scale@^6.0.0
Updatedvega-statistics@^1.7.1
Updatedvega-util@^1.12.1