我的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
);
我有一个这样的节点:
{{"id":"Jason","source":null,"target":null},"position":{"x":700,"y":100}}
无论我如何更改x和y,该节点始终保持在同一位置。如何更改该节点的位置?我究竟做错了什么?谢谢。
最佳答案
当您执行“ cy.layout(...)”时,位置将变为随机。
放置布局后,您应该手动更改节点的位置。
理念:
cy.lock();
//now set the positions of your nodes
//cy.elements("...")....x = x;
//cy.elements("...")....y = y;
cy.unlock();