Linkurious attributes don't work

558 Views Asked by At

I'm attempting to set "visual variables" but failing at it. the complete code is here: 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>

in the above, I'd expect that every node displayed gets rendered as a square, but it doesn't. mind you, the colours get set correctly but neither labelAlignment or type are respected.

can I not do it this way? or what am I missing?

* Update I *

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();
}

which I would expect to produce red edges and the labels inside the nodes but does neither. what else do I need?

1

There are 1 best solutions below

2
On BEST ANSWER

What node renderer do you use? Preferably use sigma.renderers.linkurious. Renderers are monkey patches of the standard renderers of Sigma. To use sigma.renderers.linkurious, simply add the files of that renderer into your code as shown in https://github.com/Linkurious/linkurious.js/blob/linkurious-version/examples/renderers-linkurious.html.

labelAlignment is not a node property, but a Sigma setting to be applied on all nodes, see https://github.com/Linkurious/linkurious.js/wiki/Settings . You cannot apply it to specific nodes.

EDIT2: fixed in https://github.com/Linkurious/linkurious.js/issues/139