【发布时间】:2015-06-27 04:45:17
【问题描述】:
我正在尝试设置“视觉变量”但失败了。完整代码在这里:http://pastebin.com/j6i1B8ie
<script type="application/javascript">
var neo = {
url: 'http://localhost:7474',
user: 'neo4j',
password: '***'
};
function customiseGraph(s) {
s.graph.nodes().forEach(function(n) {
n.type = 'square';
n.color = '#4444BB';
n.labelAlignment = 'left';
if (n.neo4j_labels[0] == 'DMSys') {
n.label = n.neo4j_data.System;
}
if (n.neo4j_labels[0] == 'DMFile') {
n.label = n.neo4j_data.Name;
n.color = '#BB4444';
}
});
s.refresh();
}
sigma.neo4j.cypher(neo,
'MATCH (n) OPTIONAL MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 100',
{ container: 'graph', type: 'canvas' },
customiseGraph
);
</script>
在上面,我希望显示的每个节点都呈现为正方形,但事实并非如此。请注意,颜色设置正确,但 labelAlignment 或 type 均未得到尊重。
我不能这样做吗?或者我错过了什么?
* 更新我 *
function customiseGraph(s) {
s.settings({
labelAlignment: 'inside',
edgeColor: 'default',
defaultEdgeColor: '#ff0000'
});
s.graph.nodes().forEach(function(n) {
n.color = '#4444BB';
if (n.neo4j_labels[0] == 'DMSys') {
n.label = n.neo4j_data.System;
}
if (n.neo4j_labels[0] == 'DMFile') {
n.label = n.neo4j_data.Name;
n.color = '#BB4444';
}
});
s.refresh();
}
我希望在节点内产生红色边缘和标签,但两者都没有。我还需要什么?
【问题讨论】:
-
最后一点:“内部”似乎在 Chrome 中有效,但在 Safari 中,如果节点不够大,无法容纳标签,它将显示在右侧并增加缩放级别没有帮助。增加节点直径可以解决此问题。在 Chrome 中,标签总是在里面,不管节点有多小
-
你救了我的命!!!
-
那么我希望我能投赞成票:)
标签: neo4j sigma.js linkurious