diff options
| author | Alon Levy <alon@pobox.com> | 2015-04-05 17:07:16 +0300 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-04-05 17:07:16 +0300 |
| commit | 51d193b4413837ef02bc0179baa21415c06210df (patch) | |
| tree | 3bfdbff500fc034898f238c6a434c898363aac52 /src | |
| parent | 40db8160e7f84e80a37d1ff45789f68bfbb60d60 (diff) | |
client/layouts: respect node.fixed
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/view/layouts.js | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/client/view/layouts.js b/src/client/view/layouts.js index b772b48f..8af9e9b6 100644 --- a/src/client/view/layouts.js +++ b/src/client/view/layouts.js @@ -103,6 +103,14 @@ function(consts, $, d3, _, rz_core) { return layout; } + function node__set_xy(node, x, y) { + if (node.fixed) { + return; + } + node.x = node.px = x; + node.y = node.py = y; + } + function layout__sync(graph, layer) { var layout = _.extend(layout__empty(graph), { _tick: function () { @@ -176,9 +184,12 @@ function(consts, $, d3, _, rz_core) { sin = Math.sin, ring_radius = Math.max(ring_distance_minimum, (Math.min.apply(null, this.wh) - 50) / (types.length + 1)); - function setxy(node, angle) { - node.x = node.px = cx + r * cos(angle); - node.y = node.py = cy + r * sin(angle); + function node__set_angle(node, angle) { + node__set_xy( + node, + cx + r * cos(angle), + cy + r * sin(angle) + ); } for (i = 0; i < types.length ; ++i) { @@ -188,7 +199,7 @@ function(consts, $, d3, _, rz_core) { if (count <= small_cutoff) { nodes.forEach(function (node, i) { - setxy(node, small_number_angles[nodes.length][i]); + node__set_angle(node, small_number_angles[nodes.length][i]); }); } else { var small_angle = Math.min(pi / 2, single_width / r), @@ -202,17 +213,17 @@ function(consts, $, d3, _, rz_core) { dangle = large_angle / (large_count + 1); angle = -pi_half + small_angle_half + dangle; for (j = 0 ; j < large_count; ++j) { - setxy(nodes[j], angle); + node__set_angle(nodes[j], angle); angle += dangle; } - setxy(nodes[large_count], pi / 2); + node__set_angle(nodes[large_count], pi / 2); dangle = large_angle / (count - large_count - 1); angle = pi_half + small_angle_half + dangle; for (j = large_count + 1 ; j < count - 1; ++j) { - setxy(nodes[j], angle); + node__set_angle(nodes[j], angle); angle += dangle; } - setxy(nodes[count - 1], 3 * pi / 2); + node__set_angle(nodes[count - 1], 3 * pi / 2); } } }); |
