2017-09-14 6 views
2
subsG = {}; 
    subNodes = []; 
    subEdges = []; 
    graphs = []; 
    level = 0; 
    limit = 1; 
    //map for searching nodes based on label 
    searchMap = {}; 
    //Create the higher level subnet graph 
    for(var key in data){ 
     if(data.hasOwnProperty(key)){ 
      node = {"color":"blue", "label":"Subnet" + key, "x": Math.random(), "y": Math.random(), "id": "n"+key, "size": 10}; 
      node.type = 'star'; 
      subNodes.push(node); 
     } 
    } 
    //Create subnets graph in sigma format 
    subsG['nodes'] = subNodes; 
    subsG['edges'] = subEdges; 
    prevGraph = {}; 
    //console.log(g); 

    s = new sigma({ 
     graph: subsG, 
     container: 'graph-container', 
     settings: { 
      drawEdges: true, 
      doubleClickEnabled: false 
     } 
    }); 
    // Start the ForceAtlas2 algorithm: 
    function start(){ 
     s.camera.goTo({ 
      x: 0, 
      y: 0, 
      angle: 0, 
      ratio: 1.5 
     }); 
     var i, 
      nodes = s.graph.nodes(), 
      len = nodes.length; 

     for (i = 0; i < len; i++) { 
      nodes[i].x = Math.cos(Math.PI * 2 * i/len); 
      nodes[i].y = Math.sin(Math.PI * 2 * i/len); 
     } 
     s.startForceAtlas2({worker: true, barnesHutOptimize: false, autostop: true}); 
     setTimeout(function(){s.stopForceAtlas2();},2000); 
    }; 

    start(); 

이 코드가 있습니다. 특정 노드에 특정 아이콘을 지정하고 싶습니다.Sigma.js의 노드에 아이콘 지정

어떻게 Sigma.js의 노드에 PNG 아이콘을 할당 할 수 있습니다.

예 : 이 스위치 노드의 서브 노드에 대한 서브넷 및 컴퓨터 아이콘 전환 아이콘.

답변

0

당신은 custom-node-renderer (https://github.com/jacomyal/sigma.js/blob/master/examples/custom-node-renderer.html)를 살펴 적이 있습니까? 각 노드에서

당신은 그 속성을 추가해야합니다

  • 유형을 '이미지'
  • URL : 이미지의 URL을

node = {"color":"blue", "label":"Subnet" + key, "x": Math.random(), "y": Math.random(), "id": "n"+key, "size": 10, type:'image', url:'https://cdn0.iconfinder.com/data/icons/30-hardware-line-icons/64/Server-128.png'};

건배

+0

내가 한을 때 가져가 그것을이, :( –

+0

을 작동하지 않는 그것은 단지 아이콘을 보여줍니다. –