d3: невозможно прочитать свойство 'weight' из undefined в реализации d3.force

Я понимаю, что вопрос задавался миллион раз. Тем не менее, я не могу понять, в чем проблема. Я пытаюсь повторить силовой ориентированный граф, как указано в ссылке ниже [http://bl.ocks.org/paulovn/9686202][1] Ссылка на jsfiddlehttp://jsfiddle.net/k8a3dyuL/ Я не могу понять, почему я получаю эту ошибку.

Я создал образец объекта json, для которого он работал как положено. Я могу установить соединение между узлами.

"nodes": [
{
  "index": 0, 
  "links": [
    1,
    2,
    3
    ], 
  "score": 7.35923957824707, 
  "level": 3, 
  "title": "Blood Diamond", 
  "cover": "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w342/wRamTzV6udKaMXrspxqOuo02zk0.jpg", 
  "label": "Blood Diamond (2006)", 
  "director": "Edward Zwick", 
  "cast": "Leonardo DiCaprio, Djimon Hounsou, Jennifer Connelly, Arnold Vosloo, David Harewood, Jimi Mistry, Michael Sheen, Marius Weyers, Stephen Collins, Ato Essandoh", 
  "year": 2006, 
  "duration": "143 minutes", 
  "genre": "Action, Drama, Adventure, Thriller", 
  "id": 1768448
},
{
  "index": 1, 
  "links": [

  ], 
  "score": 7.812180042266846, 
  "level": 2, 
  "title": "Casablanca", 
  "cover": "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w342/sm1QVZu5RKe1vXVHZooo4SZyHMx.jpg", 
  "label": "Casablanca (1942)", 
  "director": "Michael Curtiz", 
  "cast": "Humphrey Bogart, Ingrid Bergman, Paul Henreid, Claude Rains, Conrad Veidt, Sydney Greenstreet, Peter Lorre, Madeleine Lebeau, Dooley Wilson, Joy Page", 
  "year": 1942, 
  "duration": "102 minutes", 
  "genre": "Drama, Romance, War, Crime", 
  "id": 1750024
},
{
  "index": 2, 
  "links": [
    0
  ], 
  "score": 7.167639255523682, 
  "level": 2, 
  "title": "Lonely Hearts", 
  "cover": "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w342/wxsyl5wjobtYhll3rf5nGuC4kBN.jpg", 
  "label": "Lonely Hearts (2006)", 
  "director": "Todd Robinson", 
  "cast": "John Travolta, James Gandolfini, Salma Hayek, Jared Leto, Laura Dern, Dan Byrd, Alice Krige, Dagmara Dominczyk, Bailee Madison", 
  "year": 2006, 
  "duration": "108 minutes", 
  "genre": "Drama, Romance, Thriller, Crime", 
  "id": 1758379
}, 
{
  "index": 3, 
  "links": [
    1
    ], 
  "score": 7.595, 
  "level": 3, 
  "title": "Some Movie", 
  "cover": "http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w342/wRamTzV6udKaMXrspxqOuo02zk0.jpg", 
  "label": "Some Movie", 
  "director": "Edward Zwick", 
  "cast": "Leonardo DiCaprio, Djimon Hounsou, Jennifer Connelly, Arnold Vosloo, David Harewood, Jimi Mistry, Michael Sheen, Marius Weyers, Stephen Collins, Ato Essandoh", 
  "year": 2006, 
  "duration": "143 minutes", 
  "genre": "Action, Drama, Adventure, Thriller", 
  "id": 1768448
}
],
"links": [
{
  "source": 0, 
  "target": 2, 
  "weight": 0.9770450592041016
},
{
  "source": 0, 
  "target": 3, 
  "weight": 0.9770450592041016
},
{
  "source": 1, 
  "target": 1, 
  "weight": 0.9770450592041016
}
]
}

Не работает

{
"nodes": [{
    "index": 897,
    "links": [22,
    806,
    897],
    "score": "NA",
    "level": 1,
    "title": "Customer position",
    "cover": "comapny name",
    "label": "label",
    "director": "dir",
    "cast": "cast",
    "year": 2000,
    "duration": 2,
    "genre": "NA",
    "id": 897,
    "weight": 1
},
{
    "index": 737,
    "links": [737,
    869],
    "score": "NA",
    "level": 1,
    "title": "Customer position",
    "cover": "comapny name",
    "label": "label",
    "director": "dir",
    "cast": "cast",
    "year": 2000,
    "duration": 2,
    "genre": "NA",
    "id": 737,
    "weight": 1
},
{
    "index": 869,
    "links": [737,
    869],
    "score": "NA",
    "level": 1,
    "title": "Customer position",
    "cover": "comapny name",
    "label": "label",
    "director": "dir",
    "cast": "cast",
    "year": 2000,
    "duration": 2,
    "genre": "NA",
    "id": 869,
    "weight": 1
}],
"links": [
{
    "source": 737,
    "target": 869,
    "weight": 0.9770450592041016
},
{
    "source": 897,
    "target": 806,
    "weight": 0.9770450592041016
},
{
    "source": 897,
    "target": 22,
    "weight": 0.9770450592041016
}
]

}

Как я могу решить это?

Ответы на вопрос(0)

Ваш ответ на вопрос