admin管理员组文章数量:1322348
I want to add nodes at specified positions. I started off by trying to add two nodes at the same position (x=0, y=0) like so:
$(document).ready(function() {
var cy = cytoscape({
container: document.getElementById('cy'),
});
cy.add([
{ group: "nodes", data: { id: "n0" }, position: { x: 0, y: 0 } },
{ group: "nodes", data: { id: "n1" }, position: { x: 0, y: 0 } },
]);
});
And I expected it to show me two nodes at the same position, one over the other. But the result was quite unexpected. Here is what I got:
In fact, the position of the nodes remains the same no matter what values of x and y I specify. I also tried renderedPosition
instead of position
but to no avail.
I am searching the Cytoscape documentation for how to achieve what I want but I haven't been able to e up with a solution yet.
I want to add nodes at specified positions. I started off by trying to add two nodes at the same position (x=0, y=0) like so:
$(document).ready(function() {
var cy = cytoscape({
container: document.getElementById('cy'),
});
cy.add([
{ group: "nodes", data: { id: "n0" }, position: { x: 0, y: 0 } },
{ group: "nodes", data: { id: "n1" }, position: { x: 0, y: 0 } },
]);
});
And I expected it to show me two nodes at the same position, one over the other. But the result was quite unexpected. Here is what I got:
In fact, the position of the nodes remains the same no matter what values of x and y I specify. I also tried renderedPosition
instead of position
but to no avail.
I am searching the Cytoscape documentation for how to achieve what I want but I haven't been able to e up with a solution yet.
Share Improve this question asked Feb 7, 2015 at 14:44 Akshay DamleAkshay Damle 1,2503 gold badges19 silver badges33 bronze badges1 Answer
Reset to default 10Got it. I was forgetting to specify that the preset layout must be used. Added the following:
layout: {
name: 'preset'
},
to the cy object and it works.
本文标签: javascriptHow to add nodes at specified positions in CytoscapejsStack Overflow
版权声明:本文标题:javascript - How to add nodes at specified positions in Cytoscape.js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742115549a2421450.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论