graphnode0.0 -------> graphnode15.0 " but when i contruct json object i always get "graphnod..." /> graphnode0.0 -------> graphnode15.0 " but when i contruct json object i always get "graphnod..." /> graphnode0.0 -------> graphnode15.0 " but when i contruct json object i always get "graphnod..."/>

incorrect edge direction in infoviz's Force Directed Graph

605 Views Asked by At

I am trying to show force graph like "graphnode6.0-----> graphnode0.0 -------> graphnode15.0 " but when i contruct json object i always get "graphnode6.0------> graphnode0.0 <---------graphnode15.0" My JSON object is

var json = [
{
  "adjacencies": [  
  {
      "nodeTo": "graphnode15.0", 
      "data": {"$type":"arrow",
      "$direction":"['graphnode0.0','graphnode15.0']"}
    }  
  ], 
  "data": {
    '$color': "#83548B", 
    '$type': "circle"
  }, 
  "id": "graphnode0.0", 
  "name": "graphnode0.0"
},
{
  "adjacencies": [    
     {
      "nodeTo": "graphnode0.0", 
      "data": {"$type":"arrow",
      "$direction":"['graphnode6.0','graphnode0.0']"}
    }], 
  "data": {
    "$color": "#83548B", 
    "$type": "circle"
  }, 
  "id": "graphnode6.0", 
  "name": "graphnode6.0"
}

];

Am i making any mistake in this JSON structure ? Thanks Sumit

2

There are 2 best solutions below

0
On

I had a similar problem but thanks to your quick demo, I think I've managed to fix both our issues :)

Use double quote inside your direction block.

"$direction":["graphnode1", "nodeZ"]

When I tried with single quotes

"$direction":['graphnode1', 'nodeZ']

the arrows would render in one direction only. Hope it works for you!

0
On

You are using a string for the $direction property.

"$direction":"['graphnode6.0','graphnode0.0']"

It should be an array. Like this:

"$direction":["graphnode6.0","graphnode0.0"]

See this example code.