Comparing version 0.0.2 to 0.0.3
@@ -7,3 +7,3 @@ (function (global, factory) { | ||
var version = "0.0.2"; | ||
var version = "0.0.3"; | ||
@@ -27,3 +27,3 @@ function center(x, y) { | ||
for (sx = sx / n - x, sy = y / n - y, i = 0; i < n; ++i) { | ||
for (sx = sx / n - x, sy = sy / n - y, i = 0; i < n; ++i) { | ||
node = nodes[i], node.x -= sx, node.y -= sy; | ||
@@ -30,0 +30,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-quadtree"),require("d3-collection"),require("d3-dispatch"),require("d3-timer")):"function"==typeof define&&define.amd?define(["exports","d3-quadtree","d3-collection","d3-dispatch","d3-timer"],t):t(n.d3_force=n.d3_force||{},n.d3_quadtree,n.d3_collection,n.d3_dispatch,n.d3_timer)}(this,function(n,t,e,r,i){"use strict";function o(n,t){function e(){var e,i,o=r.length,u=0,a=0;for(e=0;o>e;++e)i=r[e],u+=i.x,a+=i.y;for(u=u/o-n,a=t/o-t,e=0;o>e;++e)i=r[e],i.x-=u,i.y-=a}var r;return null==n&&(n=0),null==t&&(t=0),e.initialize=function(n){r=n.nodes()},e.x=function(t){return arguments.length?(n=+t,e):n},e.y=function(n){return arguments.length?(t=+n,e):t},e}function u(n){return function(){return n}}function a(n){return n.x+n.vx}function f(n){return n.y+n.vy}function c(){function n(){function n(n,t,e,i,a){if(t>d||c>i||e>h||l>a)return!0;if(!n.length){var f=y-n.data.x-n.data.vx,s=v-n.data.y-n.data.vy,x=f*f+s*s,g=r[o]+r[n.data.index];g*g>x&&(x=Math.sqrt(x),x=(x-g)/(2*x),u.x-=(f-u.vx)*x,u.y-=(s-u.vy)*x)}}var o,u,c,l,d,h,s,y,v,x=e.length,g=t.quadtree(e,a,f);for(o=0;x>o;++o)u=e[o],y=u.x+u.vx,v=u.y+u.vy,s=r[o]+i,c=y-s,l=v-s,d=y+s,h=v+s,g.remove(u).visit(n).add(u)}var e,r,i,o=u(1);return n.initialize=function(n){e=n.nodes();var t,u,a=e.length;for(r=new Array(a),i=0,t=0;a>t;++t)(r[t]=u=+o(e[t],t,e))>i&&(i=u)},n.radius=function(t){return arguments.length?(o="function"==typeof t?t:u(+t),n):o},n}function l(n,t){return t}function d(n){function t(t){for(var e,r,u,a,c,l,d,h=0,s=n.length;s>h;++h)e=n[h],r=e.source,u=e.target,a=u.x-r.x,c=u.y-r.y,(l=a*a+c*c)?(l=Math.sqrt(l),l=(l-o[h])/l):(l=Math.random()*p,a=Math.cos(l),c=Math.sin(l),l=o[h]),l*=t*i[h],a*=l,c*=l,u.vx-=a*(d=f[h]),u.vy-=c*d,r.vx+=a*(d=1-d),r.vy+=c*d}function r(){if(a&&n){var t,r,u=a.length,l=n.length,s=new Array(u),y=e.map(a,c);for(t=0;u>t;++t)s[t]=0;for(t=0,f=new Array(l);l>t;++t)r=n[t],r.index=t,"object"!=typeof r.source&&(r.source=y.get(r.source)),"object"!=typeof r.target&&(r.target=y.get(r.target)),++s[r.source.index],++s[r.target.index];for(t=0;l>t;++t)r=n[t],f[t]=s[r.source.index]/(s[r.source.index]+s[r.target.index]);if(!i)for(t=0,i=new Array(l);l>t;++t)i[t]=+d(n[t]);if(!o)for(t=0,o=new Array(l);l>t;++t)o[t]=+h(n[t])}}var i,o,a,f,c=l,d=u(.5),h=u(30);return t.initialize=function(n){a=n.nodes(),r()},t.links=function(e){return arguments.length?(n=e,r(),t):n},t.id=function(n){return arguments.length?(c=n,r(),t):c},t.strength=function(n){return arguments.length?(d="function"==typeof n?n:u(+n),i=null,r(),t):d},t.distance=function(n){return arguments.length?(h="function"==typeof n?n:u(+n),o=null,r(),t):h},t}function h(n){return n.x}function s(n){return n.y}function y(){function n(n){var e,u=o.length,c=t.quadtree(o,h,s).visitAfter(r);for(f=n,e=0;u>e;++e)c.remove(a=o[e]).visit(i).add(a)}function e(){if(o){var n,t=o.length;for(c=new Array(t),n=0;t>n;++n)c[n]=+l(o[n],n,o)}}function r(n){var t,e,r,i,o,u=0;if(n.length){for(r=i=o=0;4>o;++o)(t=n[o])&&(e=t.value)&&(u+=e,r+=e*t.x,i+=e*t.y);n.x=r/u,n.y=i/u}else{t=n,t.x=t.data.x,t.y=t.data.y;do u+=c[t.data.index];while(t=t.next)}n.value=u}function i(n,t,e,r){if(!n.value)return!0;var i=n.x-a.x,o=n.y-a.y,u=r-t,l=i*i+o*o;if(d>l&&(l||(l=Math.random()*M,i=Math.cos(l),o=Math.sin(l),l=1),l=Math.sqrt(l/d),i/=l,o/=l,l=d),l>u*u/v)return y>l&&(l=n.value*f/l,a.vx+=i*l,a.vy+=o*l),!0;if(!(n.length||l>=y))do u=c[n.data.index]*f/l,a.vx+=i*u,a.vy+=o*u;while(n=n.next)}var o,a,f,c,l=u(-100),d=1,y=1/0,v=.81;return n.initialize=function(n){o=n.nodes(),e()},n.strength=function(t){return arguments.length?(l="function"==typeof t?t:u(+t),e(),n):l},n.distanceMin=function(t){return arguments.length?(d=t*t,n):Math.sqrt(d)},n.distanceMax=function(t){return arguments.length?(y=t*t,n):Math.sqrt(y)},n.theta=function(t){return arguments.length?(v=t*t,n):Math.sqrt(v)},n}function v(n,t){function e(n){for(var t,e,r=0,u=i.length;u>r;++r)t=i[r],e=o[r]*n,t.vx+=(a[r]-t.x)*e,t.vy+=(f[r]-t.y)*e}function r(){if(i){var e,r=i.length;for(o=new Array(r),a=new Array(r),f=new Array(r),e=0;r>e;++e)o[e]=+c(i[e],e,i),a[e]=+n(i[e],e,i),f[e]=+t(i[e],e,i)}}var i,o,a,f,c=u(.1);return null==n&&(n=u(0)),null==t&&(t=u(0)),e.initialize=function(n){i=n.nodes(),r()},e.strength=function(n){return arguments.length?(c="function"==typeof n?n:u(+n),r(),e):c},e.x=function(t){return arguments.length?(n="function"==typeof t?t:u(+t),r(),e):n},e.y=function(n){return arguments.length?(t="function"==typeof n?n:u(+n),r(),e):t},e}function x(n){function t(){return 1/0>d?(d=0,h=1):(d=0,h=1,p.call("start",l),g.restart(u)),l}function o(){return 1/0>d&&(d=1/0,h=0,p.call("end",l),g.stop()),l}function u(){if(h=Math.exp(++d*y),!(h>s))return o();x.each(c);for(var t,e=0,r=n.length;r>e;++e)t=n[e],t.x+=t.vx*=v,t.y+=t.vy*=v;p.call("tick",l)}function a(){for(var t,e=0,r=n.length;r>e;++e)t=n[e],t.index=e,isNaN(t.x)&&(t.x=100*Math.random()-50),isNaN(t.y)&&(t.y=100*Math.random()-50),isNaN(t.vx)&&(t.vx=0),isNaN(t.vy)&&(t.vy=0)}function f(n){return n.initialize&&n.initialize(l),n}function c(n){n(h)}var l,d=0,h=1,s=1e-4,y=-.02,v=.5,x=e.map(),g=i.timer(u),p=r.dispatch("start","tick","end");return a(),l={start:t,stop:o,tick:u,nodes:function(t){return arguments.length?(n=t,a(),x.each(f),l):n},alphaMin:function(n){return arguments.length?(s=n,l):s},alphaDecay:function(n){return arguments.length?(y=-n,d=y?Math.round(Math.log(h)/y):0,l):-y},friction:function(n){return arguments.length?(v=1-n,l):1-v},force:function(n,t){return arguments.length>1?(null==t?x.remove(n):x.set(n,f(t)),l):x.get(n)},on:function(n,t){return arguments.length>1?(p.on(n,t),l):p.on(n)}}}var g="0.0.2",p=2*Math.PI,M=2*Math.PI;n.version=g,n.forceCenter=o,n.forceCollide=c,n.forceLink=d,n.forceManyBody=y,n.forcePosition=v,n.forceSimulation=x}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-quadtree"),require("d3-collection"),require("d3-dispatch"),require("d3-timer")):"function"==typeof define&&define.amd?define(["exports","d3-quadtree","d3-collection","d3-dispatch","d3-timer"],t):t(n.d3_force=n.d3_force||{},n.d3_quadtree,n.d3_collection,n.d3_dispatch,n.d3_timer)}(this,function(n,t,e,r,i){"use strict";function o(n,t){function e(){var e,i,o=r.length,u=0,a=0;for(e=0;o>e;++e)i=r[e],u+=i.x,a+=i.y;for(u=u/o-n,a=a/o-t,e=0;o>e;++e)i=r[e],i.x-=u,i.y-=a}var r;return null==n&&(n=0),null==t&&(t=0),e.initialize=function(n){r=n.nodes()},e.x=function(t){return arguments.length?(n=+t,e):n},e.y=function(n){return arguments.length?(t=+n,e):t},e}function u(n){return function(){return n}}function a(n){return n.x+n.vx}function f(n){return n.y+n.vy}function c(){function n(){function n(n,t,e,i,a){if(t>d||c>i||e>h||l>a)return!0;if(!n.length){var f=y-n.data.x-n.data.vx,s=v-n.data.y-n.data.vy,x=f*f+s*s,g=r[o]+r[n.data.index];g*g>x&&(x=Math.sqrt(x),x=(x-g)/(2*x),u.x-=(f-u.vx)*x,u.y-=(s-u.vy)*x)}}var o,u,c,l,d,h,s,y,v,x=e.length,g=t.quadtree(e,a,f);for(o=0;x>o;++o)u=e[o],y=u.x+u.vx,v=u.y+u.vy,s=r[o]+i,c=y-s,l=v-s,d=y+s,h=v+s,g.remove(u).visit(n).add(u)}var e,r,i,o=u(1);return n.initialize=function(n){e=n.nodes();var t,u,a=e.length;for(r=new Array(a),i=0,t=0;a>t;++t)(r[t]=u=+o(e[t],t,e))>i&&(i=u)},n.radius=function(t){return arguments.length?(o="function"==typeof t?t:u(+t),n):o},n}function l(n,t){return t}function d(n){function t(t){for(var e,r,u,a,c,l,d,h=0,s=n.length;s>h;++h)e=n[h],r=e.source,u=e.target,a=u.x-r.x,c=u.y-r.y,(l=a*a+c*c)?(l=Math.sqrt(l),l=(l-o[h])/l):(l=Math.random()*p,a=Math.cos(l),c=Math.sin(l),l=o[h]),l*=t*i[h],a*=l,c*=l,u.vx-=a*(d=f[h]),u.vy-=c*d,r.vx+=a*(d=1-d),r.vy+=c*d}function r(){if(a&&n){var t,r,u=a.length,l=n.length,s=new Array(u),y=e.map(a,c);for(t=0;u>t;++t)s[t]=0;for(t=0,f=new Array(l);l>t;++t)r=n[t],r.index=t,"object"!=typeof r.source&&(r.source=y.get(r.source)),"object"!=typeof r.target&&(r.target=y.get(r.target)),++s[r.source.index],++s[r.target.index];for(t=0;l>t;++t)r=n[t],f[t]=s[r.source.index]/(s[r.source.index]+s[r.target.index]);if(!i)for(t=0,i=new Array(l);l>t;++t)i[t]=+d(n[t]);if(!o)for(t=0,o=new Array(l);l>t;++t)o[t]=+h(n[t])}}var i,o,a,f,c=l,d=u(.5),h=u(30);return t.initialize=function(n){a=n.nodes(),r()},t.links=function(e){return arguments.length?(n=e,r(),t):n},t.id=function(n){return arguments.length?(c=n,r(),t):c},t.strength=function(n){return arguments.length?(d="function"==typeof n?n:u(+n),i=null,r(),t):d},t.distance=function(n){return arguments.length?(h="function"==typeof n?n:u(+n),o=null,r(),t):h},t}function h(n){return n.x}function s(n){return n.y}function y(){function n(n){var e,u=o.length,c=t.quadtree(o,h,s).visitAfter(r);for(f=n,e=0;u>e;++e)c.remove(a=o[e]).visit(i).add(a)}function e(){if(o){var n,t=o.length;for(c=new Array(t),n=0;t>n;++n)c[n]=+l(o[n],n,o)}}function r(n){var t,e,r,i,o,u=0;if(n.length){for(r=i=o=0;4>o;++o)(t=n[o])&&(e=t.value)&&(u+=e,r+=e*t.x,i+=e*t.y);n.x=r/u,n.y=i/u}else{t=n,t.x=t.data.x,t.y=t.data.y;do u+=c[t.data.index];while(t=t.next)}n.value=u}function i(n,t,e,r){if(!n.value)return!0;var i=n.x-a.x,o=n.y-a.y,u=r-t,l=i*i+o*o;if(d>l&&(l||(l=Math.random()*M,i=Math.cos(l),o=Math.sin(l),l=1),l=Math.sqrt(l/d),i/=l,o/=l,l=d),l>u*u/v)return y>l&&(l=n.value*f/l,a.vx+=i*l,a.vy+=o*l),!0;if(!(n.length||l>=y))do u=c[n.data.index]*f/l,a.vx+=i*u,a.vy+=o*u;while(n=n.next)}var o,a,f,c,l=u(-100),d=1,y=1/0,v=.81;return n.initialize=function(n){o=n.nodes(),e()},n.strength=function(t){return arguments.length?(l="function"==typeof t?t:u(+t),e(),n):l},n.distanceMin=function(t){return arguments.length?(d=t*t,n):Math.sqrt(d)},n.distanceMax=function(t){return arguments.length?(y=t*t,n):Math.sqrt(y)},n.theta=function(t){return arguments.length?(v=t*t,n):Math.sqrt(v)},n}function v(n,t){function e(n){for(var t,e,r=0,u=i.length;u>r;++r)t=i[r],e=o[r]*n,t.vx+=(a[r]-t.x)*e,t.vy+=(f[r]-t.y)*e}function r(){if(i){var e,r=i.length;for(o=new Array(r),a=new Array(r),f=new Array(r),e=0;r>e;++e)o[e]=+c(i[e],e,i),a[e]=+n(i[e],e,i),f[e]=+t(i[e],e,i)}}var i,o,a,f,c=u(.1);return null==n&&(n=u(0)),null==t&&(t=u(0)),e.initialize=function(n){i=n.nodes(),r()},e.strength=function(n){return arguments.length?(c="function"==typeof n?n:u(+n),r(),e):c},e.x=function(t){return arguments.length?(n="function"==typeof t?t:u(+t),r(),e):n},e.y=function(n){return arguments.length?(t="function"==typeof n?n:u(+n),r(),e):t},e}function x(n){function t(){return 1/0>d?(d=0,h=1):(d=0,h=1,p.call("start",l),g.restart(u)),l}function o(){return 1/0>d&&(d=1/0,h=0,p.call("end",l),g.stop()),l}function u(){if(h=Math.exp(++d*y),!(h>s))return o();x.each(c);for(var t,e=0,r=n.length;r>e;++e)t=n[e],t.x+=t.vx*=v,t.y+=t.vy*=v;p.call("tick",l)}function a(){for(var t,e=0,r=n.length;r>e;++e)t=n[e],t.index=e,isNaN(t.x)&&(t.x=100*Math.random()-50),isNaN(t.y)&&(t.y=100*Math.random()-50),isNaN(t.vx)&&(t.vx=0),isNaN(t.vy)&&(t.vy=0)}function f(n){return n.initialize&&n.initialize(l),n}function c(n){n(h)}var l,d=0,h=1,s=1e-4,y=-.02,v=.5,x=e.map(),g=i.timer(u),p=r.dispatch("start","tick","end");return a(),l={start:t,stop:o,tick:u,nodes:function(t){return arguments.length?(n=t,a(),x.each(f),l):n},alphaMin:function(n){return arguments.length?(s=n,l):s},alphaDecay:function(n){return arguments.length?(y=-n,d=y?Math.round(Math.log(h)/y):0,l):-y},friction:function(n){return arguments.length?(v=1-n,l):1-v},force:function(n,t){return arguments.length>1?(null==t?x.remove(n):x.set(n,f(t)),l):x.get(n)},on:function(n,t){return arguments.length>1?(p.on(n,t),l):p.on(n)}}}var g="0.0.3",p=2*Math.PI,M=2*Math.PI;n.version=g,n.forceCenter=o,n.forceCollide=c,n.forceLink=d,n.forceManyBody=y,n.forcePosition=v,n.forceSimulation=x}); |
export var name = "d3-force"; | ||
export var version = "0.0.2"; | ||
export var version = "0.0.3"; | ||
export var description = "Force-directed graph layout using velocity Verlet integration."; | ||
@@ -4,0 +4,0 @@ export var keywords = ["d3","layout","network","graphc","force","verlet","infovis"]; |
{ | ||
"name": "d3-force", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Force-directed graph layout using velocity Verlet integration.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -18,3 +18,3 @@ export default function(x, y) { | ||
for (sx = sx / n - x, sy = y / n - y, i = 0; i < n; ++i) { | ||
for (sx = sx / n - x, sy = sy / n - y, i = 0; i < n; ++i) { | ||
node = nodes[i], node.x -= sx, node.y -= sy; | ||
@@ -21,0 +21,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
37064
0