2017-05-02 2 views
0

のノードの位置を設定する方法:私はJSでこのレイアウトオプションがありCytoscapeにJS

   var options = { 
        name: 'preset', 

        positions: undefined, // map of (node id) => (position obj); or function(node){ return somPos; } 
        zoom: undefined, // the zoom level to set (prob want fit = false if set) 
        pan: undefined, // the pan level to set (prob want fit = false if set) 
        fit: true, // whether to fit to viewport 
        padding: 30, // padding on fit 
        animate: false, // whether to transition the node positions 
        animationDuration: 500, // duration of animation in ms if enabled 
        animationEasing: undefined, // easing of animation if enabled 
        ready: undefined, // callback on layoutready 
        stop: undefined // callback on layoutstop 
       }; 


       cy.layout(options      
       ); 

をそして、私はそのようなノードがない:どんなに私はXを変更し、どのように

{{"id":"Jason","source":null,"target":null},"position":{"x":700,"y":100}} 

をyの場合、ノードは常に同じ位置にとどまります。そのノードの位置を変更するにはどうすればよいですか?私は間違って何をしていますか?ありがとう。

答えて

0

「cy.layout(...)」を実行すると、位置はランダムになります。

レイアウトをスローした後、手動でノードの位置を変更する必要があります。


アイデア:

cy.lock(); 
    //now set the positions of your nodes 
    //cy.elements("...")....x = x; 
    //cy.elements("...")....y = y; 
    cy.unlock(); 
関連する問題