diff options
| author | Alon Levy <alon@pobox.com> | 2015-02-06 11:14:24 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-02-06 11:14:24 +0200 |
| commit | 73c11e04cf18eff508d3b8269216ad97d88c848f (patch) | |
| tree | f9fa9b2c34e67da5913e8cbe9dc87b75dee8d133 /src/client/view/graph_view.js | |
| parent | 063f498953c7a5d8d5e6b23000cd4b4130e61a70 (diff) | |
client/filter: now with force layout awareness. Fixes #306 almost
Diffstat (limited to 'src/client/view/graph_view.js')
| -rw-r--r-- | src/client/view/graph_view.js | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js index 14a0b33b..0b9bf62b 100644 --- a/src/client/view/graph_view.js +++ b/src/client/view/graph_view.js @@ -118,7 +118,7 @@ function GraphView(spec) { } } - function redrawFromCheckboxChange() + function redraw__set_on_checkbox_change() { var checkboxes = $('.dropdown-item label input').asEventStream('click').onValue(function (_) { read_checkboxes(); @@ -128,6 +128,16 @@ function GraphView(spec) { ); } + function node__is_shown(d) { + var type = d.type; + return filter_states[d.type]; + } + + function link__is_shown(d) { + return node__is_shown(d.__src) && node__is_shown(d.__dst); + } + + zoom_property.onValue(function (val) { zoomInProgress = val; }); @@ -135,7 +145,7 @@ function GraphView(spec) { // Filter. FIXME: move away from here. separate element, connected via bacon property if (!temporary) { read_checkboxes(); - redrawFromCheckboxChange(); + redraw__set_on_checkbox_change(); } function range(start, end, number) { @@ -544,8 +554,8 @@ function GraphView(spec) { } if (force_enabled) { - force.nodes(graph.nodes()) - .links(graph.links()); + force.nodes(graph.nodes().filter(node__is_shown)) + .links(graph.links().filter(link__is_shown)); if (relayout) { force.alpha(0.1).start(); @@ -681,15 +691,6 @@ function GraphView(spec) { //console.log(e); //$(".debug").html(force.alpha()); // just hide them for now, and remove them from force layout afterwards, do not delete nodes/links themselves. - function node__is_shown(d) { - var type = d.type; - return filter_states[d.type]; - } - - function link__is_shown(d) { - return node__is_shown(d.__src) && node__is_shown(d.__dst); - } - var node = vis.selectAll(".node") .data(graph.nodes(), function(d) { return d.id; |
