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

d3-force

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-force - npm Package Compare versions

Comparing version 0.6.1 to 0.6.2

31

build/d3-force.js

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

var version = "0.6.1";
var version = "0.6.2";

@@ -380,2 +380,25 @@ function center(x, y) {

find: function(x, y, radius) {
var i = 0,
n = nodes.length,
dx,
dy,
d2,
node,
closest;
if (radius == null) radius = Infinity;
else radius *= radius;
for (i = 0; i < n; ++i) {
node = nodes[i];
dx = x - node.x;
dy = y - node.y;
d2 = dx * dx + dy * dy;
if (d2 < radius) closest = node, radius = d2;
}
return closest;
},
on: function(name, _) {

@@ -517,4 +540,3 @@ return arguments.length > 1 ? (event.on(name, _), simulation) : event.on(name);

for (i = 0; i < n; ++i) {
strengths[i] = +strength(nodes[i], i, nodes);
xz[i] = +x(nodes[i], i, nodes);
strengths[i] = isNaN(xz[i] = +x(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
}

@@ -559,4 +581,3 @@ }

for (i = 0; i < n; ++i) {
strengths[i] = +strength(nodes[i], i, nodes);
yz[i] = +y(nodes[i], i, nodes);
strengths[i] = isNaN(yz[i] = +y(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
}

@@ -563,0 +584,0 @@ }

2

build/d3-force.min.js

@@ -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,f=0;for(e=0;o>e;++e)i=r[e],u+=i.x,f+=i.y;for(u=u/o-n,f=f/o-t,e=0;o>e;++e)i=r[e],i.x-=u,i.y-=f}var r;return null==n&&(n=0),null==t&&(t=0),e.initialize=function(n){r=n},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 f(){return 1e-6*(Math.random()-.5)}function a(n){return n.x+n.vx}function c(n){return n.y+n.vy}function l(n){function e(){function n(n,t,r,i,o){var u=n.data,a=n.r,c=x+a;{if(!u)return t>d+c||d-c>i||r>y+c||y-c>o;if(u.index>e){var h=d-u.x-u.vx,s=y-u.y-u.vy,p=h*h+s*s;c*c>p&&(0===h&&(h=f(),p+=h*h),0===s&&(s=f(),p+=s*s),p=(c-(p=Math.sqrt(p)))/p*l,v.vx+=(h*=p)*(c=(a*=a)/(g+a)),v.vy+=(s*=p)*c,u.vx-=h*(c=1-c),u.vy-=s*c)}}}for(var e,u,v,d,y,x,g,s=i.length,p=0;h>p;++p)for(u=t.quadtree(i,a,c).visitAfter(r),e=0;s>e;++e)v=i[e],x=o[e],g=x*x,d=v.x+v.vx,y=v.y+v.vy,u.visit(n)}function r(n){if(n.data)return n.r=o[n.data.index];for(var t=n.r=0;4>t;++t)n[t]&&n[t].r>n.r&&(n.r=n[t].r)}var i,o,l=1,h=1;return"function"!=typeof n&&(n=u(null==n?1:+n)),e.initialize=function(t){var e,r=(i=t).length;for(o=new Array(r),e=0;r>e;++e)o[e]=+n(i[e],e,i)},e.iterations=function(n){return arguments.length?(h=+n,e):h},e.strength=function(n){return arguments.length?(l=+n,e):l},e.radius=function(t){return arguments.length?(n="function"==typeof t?t:u(+t),e):n},e}function h(n,t){return t}function v(n){function t(n){return 1/Math.min(d[n.source.index],d[n.target.index])}function r(t){for(var e=0,r=n.length;p>e;++e)for(var i,o,u,a,h,v,d,x=0;r>x;++x)i=n[x],o=i.source,u=i.target,a=u.x+u.vx-o.x-o.vx||f(),h=u.y+u.vy-o.y-o.vy||f(),v=Math.sqrt(a*a+h*h),v=(v-l[x])/v*t*c[x],a*=v,h*=v,u.vx-=a*(d=y[x]),u.vy-=h*d,o.vx+=a*(d=1-d),o.vy+=h*d}function i(){if(v){var t,r,i=v.length,u=n.length,f=e.map(v,x);for(t=0,d=new Array(i);i>t;++t)d[t]=0;for(t=0;u>t;++t)r=n[t],r.index=t,"object"!=typeof r.source&&(r.source=f.get(r.source)),"object"!=typeof r.target&&(r.target=f.get(r.target)),++d[r.source.index],++d[r.target.index];for(t=0,y=new Array(u);u>t;++t)r=n[t],y[t]=d[r.source.index]/(d[r.source.index]+d[r.target.index]);c=new Array(u),o(),l=new Array(u),a()}}function o(){if(v)for(var t=0,e=n.length;e>t;++t)c[t]=+g(n[t],t,n)}function a(){if(v)for(var t=0,e=n.length;e>t;++t)l[t]=+s(n[t],t,n)}var c,l,v,d,y,x=h,g=t,s=u(30),p=1;return null==n&&(n=[]),r.initialize=function(n){v=n,i()},r.links=function(t){return arguments.length?(n=t,i(),r):n},r.id=function(n){return arguments.length?(x=n,r):x},r.iterations=function(n){return arguments.length?(p=+n,r):p},r.strength=function(n){return arguments.length?(g="function"==typeof n?n:u(+n),o(),r):g},r.distance=function(n){return arguments.length?(s="function"==typeof n?n:u(+n),a(),r):s},r}function d(n){return n.x}function y(n){return n.y}function x(n){function t(){o(),s.call("tick",a),l>c&&(g.stop(),s.call("end",a))}function o(){var t,e,r,i=n.length;for(c+=(v-c)*h,y.each(function(n){n(c)}),t=0;i>t;++t)e=n[t],e.x+=e.vx*=d,e.y+=e.vy*=d;for(t in x)r=x[t],e=n[t],e.x=r.x,e.y=r.y,e.vx=e.vy=0}function u(){for(var t,e=0,r=n.length;r>e;++e){if(t=n[e],t.index=e,isNaN(t.x)||isNaN(t.y)){var i=q*Math.sqrt(e),o=e*w;t.x=i*Math.cos(o),t.y=i*Math.sin(o)}(isNaN(t.vx)||isNaN(t.vy))&&(t.vx=t.vy=0)}}function f(t){return t.initialize&&t.initialize(n),t}var a,c=1,l=.001,h=1-Math.pow(l,1/300),v=0,d=.6,y=e.map(),x={},g=i.timer(t),s=r.dispatch("tick","end");return null==n&&(n=[]),u(),a={tick:o,restart:function(){return g.restart(t),a},stop:function(){return g.stop(),a},nodes:function(t){return arguments.length?(n=t,u(),y.each(f),a):n},alpha:function(n){return arguments.length?(c=+n,a):c},alphaMin:function(n){return arguments.length?(l=+n,a):l},alphaDecay:function(n){return arguments.length?(h=+n,a):+h},alphaTarget:function(n){return arguments.length?(v=+n,a):v},drag:function(n){return arguments.length?(d=1-n,a):1-d},force:function(n,t){return arguments.length>1?(null==t?y.remove(n):y.set(n,f(t)),a):y.get(n)},fix:function(n,t,e){return x[n.index]={x:null==t?n.x:+t,y:null==e?n.y:+e},a},unfix:function(n){return delete x[n.index],a},on:function(n,t){return arguments.length>1?(s.on(n,t),a):s.on(n)}}}function g(){function n(n){var e,u=o.length,f=t.quadtree(o,d,y).visitAfter(r);for(c=n,e=0;u>e;++e)a=o[e],f.visit(i)}function e(){if(o){var n,t=o.length;for(l=new Array(t),n=0;t>n;++n)l[n]=+h(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+=l[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,h=i*i+o*o;if(h>u*u/g)return x>h&&(0===i&&(i=f(),h+=i*i),0===o&&(o=f(),h+=o*o),v>h&&(h=Math.sqrt(v*h)),a.vx+=i*n.value*c/h,a.vy+=o*n.value*c/h),!0;if(!(n.length||h>=x)){(n.data!==a||n.next)&&(0===i&&(i=f(),h+=i*i),0===o&&(o=f(),h+=o*o),v>h&&(h=Math.sqrt(v*h)));do n.data!==a&&(u=l[n.data.index]*c/h,a.vx+=i*u,a.vy+=o*u);while(n=n.next)}}var o,a,c,l,h=u(-30),v=1,x=1/0,g=.81;return n.initialize=function(n){o=n,e()},n.strength=function(t){return arguments.length?(h="function"==typeof t?t:u(+t),e(),n):h},n.distanceMin=function(t){return arguments.length?(v=t*t,n):Math.sqrt(v)},n.distanceMax=function(t){return arguments.length?(x=t*t,n):Math.sqrt(x)},n.theta=function(t){return arguments.length?(g=t*t,n):Math.sqrt(g)},n}function s(n){function t(n){for(var t,e=0,u=r.length;u>e;++e)t=r[e],t.vx+=(o[e]-t.x)*i[e]*n}function e(){if(r){var t,e=r.length;for(i=new Array(e),o=new Array(e),t=0;e>t;++t)i[t]=+f(r[t],t,r),o[t]=+n(r[t],t,r)}}var r,i,o,f=u(.1);return"function"!=typeof n&&(n=u(null==n?0:+n)),t.initialize=function(n){r=n,e()},t.strength=function(n){return arguments.length?(f="function"==typeof n?n:u(+n),e(),t):f},t.x=function(r){return arguments.length?(n="function"==typeof r?r:u(+r),e(),t):n},t}function p(n){function t(n){for(var t,e=0,u=r.length;u>e;++e)t=r[e],t.vy+=(o[e]-t.y)*i[e]*n}function e(){if(r){var t,e=r.length;for(i=new Array(e),o=new Array(e),t=0;e>t;++t)i[t]=+f(r[t],t,r),o[t]=+n(r[t],t,r)}}var r,i,o,f=u(.1);return"function"!=typeof n&&(n=u(null==n?0:+n)),t.initialize=function(n){r=n,e()},t.strength=function(n){return arguments.length?(f="function"==typeof n?n:u(+n),e(),t):f},t.y=function(r){return arguments.length?(n="function"==typeof r?r:u(+r),e(),t):n},t}var M="0.6.1",q=10,w=Math.PI*(3-Math.sqrt(5));n.version=M,n.forceCenter=o,n.forceCollide=l,n.forceLink=v,n.forceManyBody=g,n.forceSimulation=x,n.forceX=s,n.forceY=p});
!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,r,e,i){"use strict";function u(n,t){function r(){var r,i,u=e.length,o=0,f=0;for(r=0;u>r;++r)i=e[r],o+=i.x,f+=i.y;for(o=o/u-n,f=f/u-t,r=0;u>r;++r)i=e[r],i.x-=o,i.y-=f}var e;return null==n&&(n=0),null==t&&(t=0),r.initialize=function(n){e=n},r.x=function(t){return arguments.length?(n=+t,r):n},r.y=function(n){return arguments.length?(t=+n,r):t},r}function o(n){return function(){return n}}function f(){return 1e-6*(Math.random()-.5)}function a(n){return n.x+n.vx}function c(n){return n.y+n.vy}function l(n){function r(){function n(n,t,e,i,u){var o=n.data,a=n.r,c=x+a;{if(!o)return t>d+c||d-c>i||e>y+c||y-c>u;if(o.index>r){var h=d-o.x-o.vx,s=y-o.y-o.vy,p=h*h+s*s;c*c>p&&(0===h&&(h=f(),p+=h*h),0===s&&(s=f(),p+=s*s),p=(c-(p=Math.sqrt(p)))/p*l,v.vx+=(h*=p)*(c=(a*=a)/(g+a)),v.vy+=(s*=p)*c,o.vx-=h*(c=1-c),o.vy-=s*c)}}}for(var r,o,v,d,y,x,g,s=i.length,p=0;h>p;++p)for(o=t.quadtree(i,a,c).visitAfter(e),r=0;s>r;++r)v=i[r],x=u[r],g=x*x,d=v.x+v.vx,y=v.y+v.vy,o.visit(n)}function e(n){if(n.data)return n.r=u[n.data.index];for(var t=n.r=0;4>t;++t)n[t]&&n[t].r>n.r&&(n.r=n[t].r)}var i,u,l=1,h=1;return"function"!=typeof n&&(n=o(null==n?1:+n)),r.initialize=function(t){var r,e=(i=t).length;for(u=new Array(e),r=0;e>r;++r)u[r]=+n(i[r],r,i)},r.iterations=function(n){return arguments.length?(h=+n,r):h},r.strength=function(n){return arguments.length?(l=+n,r):l},r.radius=function(t){return arguments.length?(n="function"==typeof t?t:o(+t),r):n},r}function h(n,t){return t}function v(n){function t(n){return 1/Math.min(d[n.source.index],d[n.target.index])}function e(t){for(var r=0,e=n.length;p>r;++r)for(var i,u,o,a,h,v,d,x=0;e>x;++x)i=n[x],u=i.source,o=i.target,a=o.x+o.vx-u.x-u.vx||f(),h=o.y+o.vy-u.y-u.vy||f(),v=Math.sqrt(a*a+h*h),v=(v-l[x])/v*t*c[x],a*=v,h*=v,o.vx-=a*(d=y[x]),o.vy-=h*d,u.vx+=a*(d=1-d),u.vy+=h*d}function i(){if(v){var t,e,i=v.length,o=n.length,f=r.map(v,x);for(t=0,d=new Array(i);i>t;++t)d[t]=0;for(t=0;o>t;++t)e=n[t],e.index=t,"object"!=typeof e.source&&(e.source=f.get(e.source)),"object"!=typeof e.target&&(e.target=f.get(e.target)),++d[e.source.index],++d[e.target.index];for(t=0,y=new Array(o);o>t;++t)e=n[t],y[t]=d[e.source.index]/(d[e.source.index]+d[e.target.index]);c=new Array(o),u(),l=new Array(o),a()}}function u(){if(v)for(var t=0,r=n.length;r>t;++t)c[t]=+g(n[t],t,n)}function a(){if(v)for(var t=0,r=n.length;r>t;++t)l[t]=+s(n[t],t,n)}var c,l,v,d,y,x=h,g=t,s=o(30),p=1;return null==n&&(n=[]),e.initialize=function(n){v=n,i()},e.links=function(t){return arguments.length?(n=t,i(),e):n},e.id=function(n){return arguments.length?(x=n,e):x},e.iterations=function(n){return arguments.length?(p=+n,e):p},e.strength=function(n){return arguments.length?(g="function"==typeof n?n:o(+n),u(),e):g},e.distance=function(n){return arguments.length?(s="function"==typeof n?n:o(+n),a(),e):s},e}function d(n){return n.x}function y(n){return n.y}function x(n){function t(){u(),s.call("tick",a),l>c&&(g.stop(),s.call("end",a))}function u(){var t,r,e,i=n.length;for(c+=(v-c)*h,y.each(function(n){n(c)}),t=0;i>t;++t)r=n[t],r.x+=r.vx*=d,r.y+=r.vy*=d;for(t in x)e=x[t],r=n[t],r.x=e.x,r.y=e.y,r.vx=r.vy=0}function o(){for(var t,r=0,e=n.length;e>r;++r){if(t=n[r],t.index=r,isNaN(t.x)||isNaN(t.y)){var i=q*Math.sqrt(r),u=r*w;t.x=i*Math.cos(u),t.y=i*Math.sin(u)}(isNaN(t.vx)||isNaN(t.vy))&&(t.vx=t.vy=0)}}function f(t){return t.initialize&&t.initialize(n),t}var a,c=1,l=.001,h=1-Math.pow(l,1/300),v=0,d=.6,y=r.map(),x={},g=i.timer(t),s=e.dispatch("tick","end");return null==n&&(n=[]),o(),a={tick:u,restart:function(){return g.restart(t),a},stop:function(){return g.stop(),a},nodes:function(t){return arguments.length?(n=t,o(),y.each(f),a):n},alpha:function(n){return arguments.length?(c=+n,a):c},alphaMin:function(n){return arguments.length?(l=+n,a):l},alphaDecay:function(n){return arguments.length?(h=+n,a):+h},alphaTarget:function(n){return arguments.length?(v=+n,a):v},drag:function(n){return arguments.length?(d=1-n,a):1-d},force:function(n,t){return arguments.length>1?(null==t?y.remove(n):y.set(n,f(t)),a):y.get(n)},fix:function(n,t,r){return x[n.index]={x:null==t?n.x:+t,y:null==r?n.y:+r},a},unfix:function(n){return delete x[n.index],a},find:function(t,r,e){var i,u,o,f,a,c=0,l=n.length;for(null==e?e=1/0:e*=e,c=0;l>c;++c)f=n[c],i=t-f.x,u=r-f.y,o=i*i+u*u,e>o&&(a=f,e=o);return a},on:function(n,t){return arguments.length>1?(s.on(n,t),a):s.on(n)}}}function g(){function n(n){var r,o=u.length,f=t.quadtree(u,d,y).visitAfter(e);for(c=n,r=0;o>r;++r)a=u[r],f.visit(i)}function r(){if(u){var n,t=u.length;for(l=new Array(t),n=0;t>n;++n)l[n]=+h(u[n],n,u)}}function e(n){var t,r,e,i,u,o=0;if(n.length){for(e=i=u=0;4>u;++u)(t=n[u])&&(r=t.value)&&(o+=r,e+=r*t.x,i+=r*t.y);n.x=e/o,n.y=i/o}else{t=n,t.x=t.data.x,t.y=t.data.y;do o+=l[t.data.index];while(t=t.next)}n.value=o}function i(n,t,r,e){if(!n.value)return!0;var i=n.x-a.x,u=n.y-a.y,o=e-t,h=i*i+u*u;if(h>o*o/g)return x>h&&(0===i&&(i=f(),h+=i*i),0===u&&(u=f(),h+=u*u),v>h&&(h=Math.sqrt(v*h)),a.vx+=i*n.value*c/h,a.vy+=u*n.value*c/h),!0;if(!(n.length||h>=x)){(n.data!==a||n.next)&&(0===i&&(i=f(),h+=i*i),0===u&&(u=f(),h+=u*u),v>h&&(h=Math.sqrt(v*h)));do n.data!==a&&(o=l[n.data.index]*c/h,a.vx+=i*o,a.vy+=u*o);while(n=n.next)}}var u,a,c,l,h=o(-30),v=1,x=1/0,g=.81;return n.initialize=function(n){u=n,r()},n.strength=function(t){return arguments.length?(h="function"==typeof t?t:o(+t),r(),n):h},n.distanceMin=function(t){return arguments.length?(v=t*t,n):Math.sqrt(v)},n.distanceMax=function(t){return arguments.length?(x=t*t,n):Math.sqrt(x)},n.theta=function(t){return arguments.length?(g=t*t,n):Math.sqrt(g)},n}function s(n){function t(n){for(var t,r=0,o=e.length;o>r;++r)t=e[r],t.vx+=(u[r]-t.x)*i[r]*n}function r(){if(e){var t,r=e.length;for(i=new Array(r),u=new Array(r),t=0;r>t;++t)i[t]=isNaN(u[t]=+n(e[t],t,e))?0:+f(e[t],t,e)}}var e,i,u,f=o(.1);return"function"!=typeof n&&(n=o(null==n?0:+n)),t.initialize=function(n){e=n,r()},t.strength=function(n){return arguments.length?(f="function"==typeof n?n:o(+n),r(),t):f},t.x=function(e){return arguments.length?(n="function"==typeof e?e:o(+e),r(),t):n},t}function p(n){function t(n){for(var t,r=0,o=e.length;o>r;++r)t=e[r],t.vy+=(u[r]-t.y)*i[r]*n}function r(){if(e){var t,r=e.length;for(i=new Array(r),u=new Array(r),t=0;r>t;++t)i[t]=isNaN(u[t]=+n(e[t],t,e))?0:+f(e[t],t,e)}}var e,i,u,f=o(.1);return"function"!=typeof n&&(n=o(null==n?0:+n)),t.initialize=function(n){e=n,r()},t.strength=function(n){return arguments.length?(f="function"==typeof n?n:o(+n),r(),t):f},t.y=function(e){return arguments.length?(n="function"==typeof e?e:o(+e),r(),t):n},t}var M="0.6.2",q=10,w=Math.PI*(3-Math.sqrt(5));n.version=M,n.forceCenter=u,n.forceCollide=l,n.forceLink=v,n.forceManyBody=g,n.forceSimulation=x,n.forceX=s,n.forceY=p});
export var name = "d3-force";
export var version = "0.6.1";
export var version = "0.6.2";
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.6.1",
"version": "0.6.2",
"description": "Force-directed graph layout using velocity Verlet integration.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -5,5 +5,5 @@ # d3-force

In the domain of information visualization, physical simulations are useful for studying [networks](http://bl.ocks.org/mbostock/f584aa36df54c451c94a9d0798caed35) and [hierarchies](http://bl.ocks.org/mbostock/95aa92e2f4e8345aaa55a4a94d41ce37)!
In the domain of information visualization, physical simulations are useful for studying [networks](http://bl.ocks.org/mbostock/ad70335eeef6d167bc36fd3c04378048) and [hierarchies](http://bl.ocks.org/mbostock/95aa92e2f4e8345aaa55a4a94d41ce37)!
[<img alt="Force-Directed Graph" src="https://raw.githubusercontent.com/d3/d3-force/master/img/graph.png" width="420" height="219">](http://bl.ocks.org/mbostock/f584aa36df54c451c94a9d0798caed35)[<img alt="Force-Directed Tree" src="https://raw.githubusercontent.com/d3/d3-force/master/img/tree.png" width="420" height="219">](http://bl.ocks.org/mbostock/95aa92e2f4e8345aaa55a4a94d41ce37)
[<img alt="Force Dragging III" src="https://raw.githubusercontent.com/d3/d3-force/master/img/graph.png" width="420" height="219">](http://bl.ocks.org/mbostock/ad70335eeef6d167bc36fd3c04378048)[<img alt="Force-Directed Tree" src="https://raw.githubusercontent.com/d3/d3-force/master/img/tree.png" width="420" height="219">](http://bl.ocks.org/mbostock/95aa92e2f4e8345aaa55a4a94d41ce37)

@@ -59,3 +59,3 @@ You can also simulate circles (disks) with collision, such as for [bubble charts](http://www.nytimes.com/interactive/2012/09/06/us/politics/convention-word-counts.html) or [beeswam plots](http://bl.ocks.org/mbostock/6526445e2b44303eebf21da3b6627320):

This method does not dispatch [events](#simulation_on); events are only dispatched by the internal timer when the simulation is started automatically upon [creation](#forceSimulation) or by calling [*simulation*.restart](#simulation_restart).
This method does not dispatch [events](#simulation_on); events are only dispatched by the internal timer when the simulation is started automatically upon [creation](#forceSimulation) or by calling [*simulation*.restart](#simulation_restart). The natural number of ticks when the simulation is started is ⌈*log*([*alphaMin*](#simulation_alphaMin)) / *log*(1 - [*alphaDecay*](#simulation_alphaDecay))⌉; by default, this is 300.

@@ -117,2 +117,6 @@ <a name="simulation_nodes" href="#simulation_nodes">#</a> <i>simulation</i>.<b>nodes</b>([<i>nodes</i>])

<a name="simulation_find" href="#simulation_find">#</a> <i>simulation</i>.<b>find</b>(<i>x</i>, <i>y</i>[, <i>radius</i>])
Returns the node closest to the position ⟨*x*,*y*⟩ with the given search *radius*. If *radius* is not specified, it defaults to infinity. If there is no node within the search area, returns undefined.
<a name="simulation_on" href="#simulation_on">#</a> <i>simulation</i>.<b>on</b>(<i>typenames</i>, [<i>listener</i>])

@@ -119,0 +123,0 @@

@@ -131,2 +131,25 @@ import {dispatch} from "d3-dispatch";

find: function(x, y, radius) {
var i = 0,
n = nodes.length,
dx,
dy,
d2,
node,
closest;
if (radius == null) radius = Infinity;
else radius *= radius;
for (i = 0; i < n; ++i) {
node = nodes[i];
dx = x - node.x;
dy = y - node.y;
d2 = dx * dx + dy * dy;
if (d2 < radius) closest = node, radius = d2;
}
return closest;
},
on: function(name, _) {

@@ -133,0 +156,0 @@ return arguments.length > 1 ? (event.on(name, _), simulation) : event.on(name);

@@ -23,4 +23,3 @@ import constant from "./constant";

for (i = 0; i < n; ++i) {
strengths[i] = +strength(nodes[i], i, nodes);
xz[i] = +x(nodes[i], i, nodes);
strengths[i] = isNaN(xz[i] = +x(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
}

@@ -27,0 +26,0 @@ }

@@ -23,4 +23,3 @@ import constant from "./constant";

for (i = 0; i < n; ++i) {
strengths[i] = +strength(nodes[i], i, nodes);
yz[i] = +y(nodes[i], i, nodes);
strengths[i] = isNaN(yz[i] = +y(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
}

@@ -27,0 +26,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