Open mgarf opened 9 years ago
+1 for this one! The springyui renderer (at line 327) seems to support a "data" property for the nodes, but how do we provide this (with JSON).
Heya,
Yep, this is possible.
The object passed at node creation is accessible as the node's data
property.
e.g.
var node = graph.newNode({ xyz: 42 });
// You can assign a label manually like this:
node.data.label = 'Hello';
// Or access a node's properties..
console.log(node.data.xyz); // => 42
Also, depending on the format of your data, if it's a JSON string you'll need to parse it first:
node.data = JSON.parse('{"label": "Hello"}')
Does that answer your question?
Hi,
I am currently using this to build out a visualization of my create your own adventure game. Currently I have a script that scans and pushes the lvl identifier into the node and edge arrays with no problem. I noticed in other examples not using JSON you are able to provide an alternate label to the node identifier. Is that possible to do in JSON?
like what is done here:
var fir = graph.newNode({label: 'Sicilian Fir'});
but with JSON.
I hope I am posting in the right place.