summaryrefslogtreecommitdiff
path: root/src/client/view/layouts.js
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2015-04-13 00:09:42 +0200
committerAlon Levy <alon@pobox.com>2015-04-13 00:09:42 +0200
commit86c149384b609d2d71e92670efbf77a7c88ddd81 (patch)
treeed01b5a770f35d62b3fa413d1f6ebfe022af860c /src/client/view/layouts.js
parent15943f4bd5bfa321d3244c245af779f9fb6f55fc (diff)
client/zen_mode/force layout: use uniform link distance
Diffstat (limited to 'src/client/view/layouts.js')
-rw-r--r--src/client/view/layouts.js27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/client/view/layouts.js b/src/client/view/layouts.js
index f93c27a3..ae16143e 100644
--- a/src/client/view/layouts.js
+++ b/src/client/view/layouts.js
@@ -100,13 +100,25 @@ function(consts, $, d3, _) {
return layout__empty(graph, d3.layout.force())
.distance(240)
.gravity(0.12)
- .charge(-1800)
- .linkDistance(function (link) {
+ .charge(-1800);
+ }
+
+ function layout__d3_force__link_distance(graph) {
+ var ret = layout__d3_force(graph);
+ ret.zen_mode = function (zen_mode) {
+ if (zen_mode) {
+ ret.distance(240)
+ } else {
+ ret.linkDistance(function (link) {
var d_src = graph.degree(link.__src),
d_dst = graph.degree(link.__dst),
ret = (d_src + d_dst) * 10 + 10;
return ret;
});
+ }
+ return ret;
+ }
+ return ret;
}
function layout__cola(graph) {
@@ -196,6 +208,8 @@ function(consts, $, d3, _) {
layout.nodes(nodes);
return layout.links(links);
},
+ // zen_mode callback - to change layout based on it.
+ zen_mode: donothing,
// data
graph: graph,
_nodes: [],
@@ -349,7 +363,7 @@ function(consts, $, d3, _) {
var layouts = [
{
name: 'Force',
- create: layout__d3_force,
+ create: layout__d3_force__link_distance,
clazz: 'btn_layout_d3_force'
},
{
@@ -359,6 +373,13 @@ function(consts, $, d3, _) {
},
/*
{
+ name: 'Force',
+ create: layout__d3_force,
+ clazz: 'btn_layout_d3_force'
+ },
+ */
+ /*
+ {
name: 'STP-BFS',
create: layout__d3_force_stp,
clazz: 'btn_layout_d3_force'