Commit d70fee75 authored by S Anand's avatar S Anand

BUG: filter_links should work before draw. Fixes #21

parent a238a70b
......@@ -317,12 +317,26 @@ _G_network.force = function() {
// Apply all link filters, and remove links to non-existent nodes
function filter_links() {
for (var links=[], i=0, link; link=data.links[i]; i++)
if ( in node_ids && in node_ids)
for (var ns in link_filter)
links = links.filter(link_filter[ns])
return links
var filtered_links = [],
i = 0,
if (links.length) {
// If we've already called .draw(), the links are resolved into objects.
// In that case, .source is an object whose .id is the node id
if (typeof links[0].source == 'object') {
for (; link=links[i]; i++)
if ( in node_ids && in node_ids)
} else {
// If we haven't called .draw() yet, the links are node IDs themselves
for (; link=links[i]; i++)
if (nodes[link.source].id in node_ids && nodes[].id in node_ids)
for (var ns in link_filter)
filtered_links = filtered_links.filter(link_filter[ns])
return filtered_links
// Filters links based on fn(link)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment