【问题标题】:Linkurious attributes don't work链接属性不起作用
【发布时间】: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>

在上面,我希望显示的每个节点都呈现为正方形,但事实并非如此。请注意,颜色设置正确,但 labelAlignmenttype 均未得到尊重。

我不能这样做吗?或者我错过了什么?

* 更新我 *

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


【解决方案1】:

您使用什么节点渲染器?最好使用 sigma.renderers.linkurious。渲染器是 Sigma 标准渲染器的猴子补丁。要使用 sigma.renderers.linkurious,只需将该渲染器的文件添加到您的代码中,如 https://github.com/Linkurious/linkurious.js/blob/linkurious-version/examples/renderers-linkurious.html 所示。

labelAlignment 不是节点属性,而是要应用于所有节点的 Sigma 设置,请参阅 https://github.com/Linkurious/linkurious.js/wiki/Settings 。您不能将其应用于特定节点。

EDIT2:固定在https://github.com/Linkurious/linkurious.js/issues/139

【讨论】:

  • 这意味着我不能为某些节点设置它而不是其他节点?
  • 我该如何选择“节点渲染器”?我选择了“画布”作为渲染器,但有什么不同呢?另外,我已经阅读了sigma.classes.configurable 的文档,但我没有看到有关如何将其连接到我的图表的文档?
猜你喜欢
  • 1970-01-01
  • 2011-06-29
  • 2021-05-27
  • 1970-01-01
  • 1970-01-01
  • 2017-08-08
  • 2016-09-26
  • 2016-10-05
  • 1970-01-01
相关资源
最近更新 更多