Uncaught The node must have a string or number id. NeoCypher
mafiqqq opened this issue · 9 comments
When I'm trying to pass my Neo4jGraphItemProducers i'm getting this error
<Sigma
renderer="canvas"
settings={ this.state.style }
onOverNode={e => e.data.node.label}
// style={this.state.settings}
>
<NeoCypher
url="http://localhost:7474"
user="neo4j"
password="root"
query=
"MATCH (c:Claim {claimID:'6000'})-[r:BASED_ON]-(a:Accident) RETURN c,r,a"
producers={new NodeGraphProducers()}
onGraphLoaded={() => console.log("Graph loaded")} >
</NeoCypher>
<RelativeSize initialSize={15} />
<RandomizeNodePositions />
</Sigma>
My producers :
export class NodeGraphProducers {
node(node: Accident): AccidentS {
return {
id: AccidentS.accidentID,
label: AccidentS.accidentDate,
x: Math.random(),
y: Math.random(),
size: 10,
color: "#5DA5DA",
neo4j_label: AccidentS.labels,
neo4j_data: AccidentS.properties
}
}
node(node: Claim): ClaimS {
return {
id: ClaimS.claimID,
label: ClaimS.claimID,
x: Math.random(),
y: Math.random(),
size: 10,
color: "#5DA5DA",
neo4j_label: ClaimS.labels,
neo4j_data: ClaimS.properties
}
}
edge(edge: INVOLVED_IN): INVOLVED_INS {
return {
id: '',
label: '',
source: edge.AccidentS,
target: edge.ClaimS,
color: "#333333",
neo4j_type: edge.type,
neo4j_data: edge.properties
}
}
}
Why am I getting the error when I want to display the graph. Thank you in advance!
@mafiqqq it is not clear which error do you get, is it compilation error or runtime? I noticed that you are using your custom types Accident
and AccidentS
, while interface requires node(node: Neo4j$Node): Sigma$Node
Sorry for troubling you, how to i define in the interface at node(node: Neo4j$Node) : Sigma$Node
Must i repeat it for each nodes i have in my Neo4j?
Accident and AccidentS i gave as a variable to declare it, which is a mistake i believe, in this context what should i write in Neo4jNode
and Sigma$Node
@mafiqqq unfortunately I have no idea why default properties take over your supplied property. I have published patch which manually validates if property producers
was supplied it should use it. Pls try react-sigma@1.2.33
Sorry for troubling you, how to i define in the interface at
node(node: Neo4j$Node) : Sigma$Node
Must i repeat it for each nodes i have in my Neo4j?Accident and AccidentS i gave as a variable to declare it, which is a mistake i believe, in this context what should i write in
Neo4jNode
andSigma$Node
I think the problem is different, if it compiles for you probably it just skips type check for sigma and you should be ok.
I think it does not overtake default producers.
node(node: Accident): nodes {
return {
id: toString(node.accidentID),
label: "Test Accident",
x: Math.random(),
y: Math.random(),
size: 10,
color: "#5DA5DA",
neo4j_label: node.labels,
neo4j_data: node.properties
}
},
by simply trying and error while debugging It does connect to producers. Right now it cant get the Nodes available in Neo4j and their properties ( or I dont know how to do that by replacing Neo4j$Node
and Sigma$Node
)
Snapshot of accessing the producers and gettting the label :
id :
label :
I just dont know how to access the nodes in Neo4j by doing so in the above. Sorry if I take your time, really need the solution as I'm doing Visualization using neo4j!
I think the problem is my producer does not connect to Neo4j
e.g I have two nodes Claim and Accident
Claim {
{
"score": 300.0,
"description": "Accident with another car",
"claimID": "6000",
"value": "8900",
"reportedDate": "19052017",
"status": "Settled"
}
}
Accident {
{
"accidentDate": "04/03/2017",
"city": "Shah Alam",
"street": "Jalan Akal 1/12A",
"latitude": "3.08132",
"postcode": "40450",
"state": "Selangor",
"policeNum": "TYF45AC45J",
"longitude": "101.73696",
"accidentID": "151",
"accidentTime": "03:58:32 GMT+0800 (Malaysia Standard Time)"
}
}
and also a relationship of (:Claim)-[:BASED_ON]->(:Accident)
How would you write the producers to access this?
Did you update the lib? In the screenshot you sent before it was clearly using default NeoGraphItemsProducer, with update it should be using yours. Since it draws at least one node it should be getting data from neo4j.
Forget about types, they cannot affect behavior they only doing compilation checks, if it compiles types should not matter at this stage. I suggest you to try and log in your function node to see if it gets the data and what is the data:
node(node) {
console.log("Got node from Neo4J");
console.log(node);
return {
id: toString(node.accidentID),
label: "Test Accident",
x: Math.random(),
y: Math.random(),
size: 10,
color: "#5DA5DA",
neo4j_label: node.labels,
neo4j_data: node.properties
}
}