我有一个小的 Neo 图表:
match (f) optional match (f)-[r]-() delete f, r;
merge (DMSrc:DMSys { Org: 'UNK-1', System: 'UNK' }) merge (DMDst:DMSys { Organization: 'UNK-0', System: 'Peoplesoft' }) merge (f:DMFile { Name: 'BAL'}) merge (DMSrc)-[:Provides]->(f)-[:Receives]->(DMDst);
merge (DMSrc:DMSys { Org: 'UNK-2', System: 'Oracle GL' }) merge (DMDst:DMSys { Organization: 'UNK-0', System: 'Peoplesoft' }) merge (f:DMFile { Name: 'BAL'}) merge (DMSrc)-[:Provides]->(f)-[:Receives]->(DMDst);
merge (DMSrc:DMSys { Org: 'X&X', System: 'Classic' }) merge (DMDst:DMSys { Organization: 'UNK-0', System: 'Peoplesoft' }) merge (f:DMFile { Name: 'BAL'}) merge (DMSrc)-[:Provides]->(f)-[:Receives]->(DMDst);
merge (DMSrc:DMSys { Org: 'UNK-3', System: 'Classic' }) merge (DMDst:DMSys { Organization: 'UNK-0', System: 'Peoplesoft' }) merge (f:DMFile { Name: 'BAL'}) merge (DMSrc)-[:Provides]->(f)-[:Receives]->(DMDst);
merge (DMSrc:DMSys { Org: 'UNK-4', System: 'Sun System' }) merge (DMDst:DMSys { Organization: 'UNK-0', System: 'Peoplesoft' }) merge (f:DMFile { Name: 'BAL'}) merge (DMSrc)-[:Provides]->(f)-[:Receives]->(DMDst);
merge (DMSrc:DMSys { Org: 'UNK-5', System: 'Oracle GL' }) merge (DMDst:DMSys { Organization: 'UNK-0', System: 'Peoplesoft' }) merge (f:DMFile { Name: 'BAL'}) merge (DMSrc)-[:Provides]->(f)-[:Receives]->(DMDst);
merge (DMSrc:DMSys { Org: 'UNK-6', System: 'Oracle GL' }) merge (DMDst:DMSys { Organization: 'UNK-0', System: 'Peoplesoft' }) merge (f:DMFile { Name: 'BAL'}) merge (DMSrc)-[:Provides]->(f)-[:Receives]->(DMDst);
merge (DMSrc:DMSys { Org: 'UNK-7', System: 'Direct (No Interface)' }) merge (DMDst:DMSys { Organization: 'UNK-0', System: 'Peoplesoft' }) merge (f:DMFile { Name: 'BAL'}) merge (DMSrc)-[:Provides]->(f)-[:Receives]->(DMDst);
我正在尝试生成一个图表,其中节点使用数据属性(Neo 中的节点属性)“系统”,但我无法让它工作。这是代码:
var neo = {
url: 'http://localhost:7474',
user: 'neo4j',
password: '***'
};
sigma.neo4j.cypher(neo,
'MATCH (n) OPTIONAL MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 100',
{ container: 'graph' },
function (s) {
sigma.plugins.killDesign(s);
var design = sigma.plugins.design(s);
design.setStyles({
nodes: {
label: { by: 'neo4j_data.System' }
}
});
design.apply();
}
);
您会注意到,与文档中的示例引用不同data.something,我使用neo4j_data.something,因为我从调试中发现,对于从 Neo4j 检索到的图形,节点属性似乎驻留。
显然,应该访问这些数据的地方是在applyStyle
定义的方法中sigma.plugins.design.js
,特别是第 534 行,我在下面引用:
if (!(visualVar in self.originalVisualVariable[item.id])) {
// non-writable property
Object.defineProperty(self.originalVisualVariable[item.id], visualVar, {
enumerable: true,
value: item[visualVar]
});
}
可以看出标签的值(visualVar 当前设置为“label”)被设置为item[visualVar]
...但是item
包含:
{
Object
cam0:size: 8
cam0:x: 656.8832126805254
cam0:y: 191.29239469613498
color: "#000000"
id: "0"
label: "0"
neo4j_data: {
Org: "UNK-1"
System: "UNK"
}
neo4j_labels: Array[1]
read_cam0:size: 8
read_cam0:x: 61.38321268052541
read_cam0:y: 91.79239469613499
size: 1
x: 0.8536414597183466
y: 0.980357211548835
__proto__: Object
}
从中可以看出,虽然有属性item.label
,但真正应该做的是retrieve item.neo4j_data.System
。
我是否误解了这一点,或者它应该如何工作?
TIA-e