Created
March 26, 2015 17:42
-
-
Save Ellisande/155e4411f9c9cc399c2a to your computer and use it in GitHub Desktop.
Add Secondary Edges
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data.relations.forEach(function(relation){ | |
console.log(typeof(relation) + "and " + relation.first_name); | |
graphData.nodes[relation.person_id] = { | |
color: 'green', | |
shape: 'dot', | |
label: relation.first_name + " " + relation.middle_name + " " + relation.last_name | |
} | |
// This line right here always adds the edge to data.person_id... | |
//but when you move to a new relation we need to add a new node to relations | |
// Since we always add to the graphData.edges[data.person_id] the new nodes will always be connected to just that person. | |
graphData.edges[data.person_id][relation.person_id] = {}; | |
//Example for a new relation | |
graphData.edges[data.new_relation][relation.person_id] = {} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// need a placeholder for 1. | |
var buildPersonNode = function(person) { | |
graphData.nodes[data.person_id] = { | |
color: "red", | |
shape: "dot", | |
label: data.first_name + " " + data.middle_name + " " + data.last_name | |
}; | |
graphData.edges[data.person_id] = {}; | |
data.relations.forEach(function(relation){ | |
console.log(typeof(relation) + "and " + relation.first_name); | |
graphData.nodes[relation.person_id] = { | |
color: 'green', | |
shape: 'dot', | |
label: relation.first_name + " " + relation.middle_name + " " + relation.last_name | |
} | |
graphData.edges[data.person_id][relation.person_id] = {}; | |
}); | |
buildPersonNode(relation); | |
} | |
} | |
$.get('api/1').success(function(data){ | |
buildPersonNode(data); | |
sys.graft(graphData); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment