Skip to content

Commit

Permalink
Fix #123 Initialize fixed nodes from f* attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
vasturiano authored and mbostock committed Oct 11, 2018
1 parent 83d4653 commit b383200
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/simulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export default function(nodes) {
function initializeNodes() {
for (var i = 0, n = nodes.length, node; i < n; ++i) {
node = nodes[i], node.index = i;
if (!isNaN(node.fx)) node.x = node.fx;
if (!isNaN(node.fy)) node.y = node.fy;
if (isNaN(node.x) || isNaN(node.y)) {
var radius = initialRadius * Math.sqrt(i), angle = i * initialAngle;
node.x = radius * Math.cos(angle);
Expand Down

0 comments on commit b383200

Please sign in to comment.