首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法读取未定义的属性'neighbours‘

无法读取未定义的属性'neighbours‘
EN

Stack Overflow用户
提问于 2015-07-31 01:37:23
回答 1查看 421关注 0票数 2

http://jsfiddle.net/eM6jU/200/

未捕获的邻居:无法读取未定义的属性‘TypeError’。

它是从下面的循环发出的,你知道为什么会发生这种情况吗?cola.js线路3332

代码语言:javascript
复制
**Watch Expressions**

    "i ": Object
    length: 144
    source: "ds"
    target: "sdf"



 while (i--) {   var e = this.es[i];
    var u = getSourceIndex(e), v = getTargetIndex(e);
    var d = getLength(e);
    this.neighbours[u].neighbours.push(new Neighbour(v, d));
    this.neighbours[v].neighbours.push(new Neighbour(u, d));`

            }
EN

回答 1

Stack Overflow用户

发布于 2021-09-13 13:37:08

在OP提交的this issue中可以找到解决方案。

基本上,cola.js要求链接采用某种格式,即源属性和目标属性需要作为节点数组的索引(而不是节点的名称)。以下是一些格式正确的数据的示例:

代码语言:javascript
复制
{
    "nodes": ["Node A", "Node B", "Node C"],
    "links": {
        {"source": 0, "target": 1},
        {"source": 1, "target": 2},
        {"source": 2, "target": 0}
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31730502

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档