1

我试图显示像“graphnode6.0-----> graphnode0.0 -------> graphnode15.0”这样的力图,但是当我构造json对象时,我总是得到“graphnode6.0---- --> graphnode0.0 <---------graphnode15.0" 我的 JSON 对象是

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"
}

];

我在这个 JSON 结构中犯了什么错误吗?谢谢苏米特

4

2 回答 2

0

我遇到了类似的问题,但是感谢您的快速演示,我想我已经设法解决了我们的两个问题:)

在方向块内使用双引号。

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

当我尝试使用单引号时

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

箭头只会在一个方向上呈现。希望这对你有用!

于 2012-08-23T09:56:40.640 回答
0

$direction您正在为属性使用字符串。

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

它应该是一个数组。像这样:

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

请参阅此示例代码。

于 2014-07-19T00:15:51.393 回答