How do I show edge labels on graphs?

前端 未结 3 664
感情败类
感情败类 2021-01-03 05:46

I am trying to load a gexf file with sigInst.parseGexf(\'data/test.gexf\').

To create an edge with label I have this line in gexf file:



        
3条回答
  •  南笙
    南笙 (楼主)
    2021-01-03 06:30

    It's now possible to do this with a new plugin in the sigma repository: https://github.com/jacomyal/sigma.js/tree/master/plugins/sigma.renderers.edgeLabels

    Just follow the instructions to build the Sigma project and you'll find this file in the /build/plugins folder: sigma.renderers.edgeLabels.min.js

    Include that in your html file:

    
    
    

    Make sure your edges have a 'label' key defined

    var data = {
        // specify 'nodes' as well
        edges: [                       
            {                          
                id: "e1",              
                source: "user", 
                target: "b1",        
                label: "This is the label", // <----- define 'label' key for your edges          
            }, 
        ]       
    }
    

    And then specify your renderer in the Sigma initialization.

    var s = new sigma({                                                    
        graph: data,                                                       
        renderer: {                                                        
            container: "container",                                        
            type: "canvas"                                                 
        },                                                                 
        settings: {
        }                                                                  
    });                                                                                                                                                  
    

提交回复
热议问题