Getting Data from NEO4J and now ?

24 views
Skip to first unread message

Andreas Dernbauer

unread,
Mar 26, 2015, 9:26:49 AM3/26/15
to d3...@googlegroups.com
Hi hopefully someone can help,

I connect to NEO4J via REST API and got some data back.

d3.json(neo4JEndPointURL)
        .header("Content-Type", "application/json")
        .post(
        JSON.stringify({
            statements: [{
                statement: "MATCH (a)-[:`srcChildOf`]->(b) RETURN a,b",
                resultDataContents: ["graph"]
            }]

The result looks like:

Under the object.graph there are a nodes array with two elements 

The NEO4J guid says: 

Converting Neo4j Query Results to D3 JSON

function idIndex(a,id) {
for (var i=0;i<a.length;i++) {
if (a[i].id == id) return i;}
return null;
}
var nodes=[], links=[];
res.results[0].data.forEach(function (row) {
row.graph.nodes.forEach(function (n) {
if (idIndex(nodes,n.id) == null)
nodes.push({id:n.id,label:n.labels[0],title:n.properties.name});
   });
links = links.concat( row.graph.relationships.map(function(r) {
return {start:idIndex(nodes,r.startNode),end:idIndex(nodes,r.endNode),type:r.type};
   }));
});
viz = {nodes:nodes, links:links};
But what is a and id which parameter should I overhanded to that function ? 

 
Thank You !
 
Reply all
Reply to author
Forward
0 new messages