我的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,节点始终保持在相同位置。如何更改该节点的位置?我究竟做错了什么?感谢。
答案 0 :(得分:0)
当你执行“cy.layout(...)”时,该位置变得随机。
抛出布局后,您应该手动更改节点的位置。
cy.lock();
//now set the positions of your nodes
//cy.elements("...")....x = x;
//cy.elements("...")....y = y;
cy.unlock();