Search code examples
javascriptedgessigma.js

SigmaJS Edge labels doesn't display


Even after doing everything I could find in Google still my network edges doesn't display their labels

I've added an issue in sigma git repo https://github.com/jacomyal/sigma.js/issues/1016

Here's my code

var i,
    j,
    s,
    N = flowgraph.length,
    E = N * (N - 1),
    g = {
        nodes: [],
        edges: []
    };

for (i = 0; i < N; i++) {
    //node code
}

for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
        if (flowgraph[i][j] > 0) {
            g.edges.push({
                id: 'e' + i + '' + j,
                source: 'n' + i,
                target: 'n' + j,
                label: 'edge' + i,
                color: '#A6A6A6',
                size: 4,
                type: 'arrow'
            });
        }
    }
}

s = new sigma({
    graph: g,
    container: 'graph-container',
    settings: {
        minEdgeSize: 1,
        maxEdgeSize: 4,
        edgeLabelSize: 'proportional',
    },
    type: 'canvas'
});

// Start the layout:
s.refresh();
```javascript

I have imported all the required plugins too 


Solution

  • Sorry for the unnecessary problem. After changing

    type: 'canvas'
    

    to

    renderer: {
            container: document.getElementById('graph-container'),
            type: sigma.renderers.canvas,
        },
    

    Issue got fixed. I will not delete the question in case anyone else face the same problem.