javascript - Calling layout on a subset of nodes in a loop does not properly layout the nodes -


i have several groups of nodes, , need each group own circle around different location.

i have loop adds nodes chart, , @ end gets nodes, , attempts circularize them.

however when run program, nodes end in grid format. how expected behavior?

    for( group in groups ){         cy.add([                 { group:'nodes', data: { id: 1, customgroup: group}, position:{x: 0,y: 0} },                 { group:'nodes', data: { id: 2, customgroup: group}, position:{x: 0,y: 0} },                 { group:'nodes', data: { id: 3, customgroup: group}, position:{x: 0,y: 0} },                 { group:'nodes', data: { id: 4, customgroup: group}, position:{x: 0,y: 0} },                 { group:'nodes', data: { id: 5, customgroup: group}, position:{x: 0,y: 0} },                 { group:'edges', data: { source: '1',target: '2', weight:1} },                 { group:'edges', data: { source: '2',target: '3', weight:1} },                 { group:'edges', data: { source: '3',target: '4', weight:1} },                 { group:'edges', data: { source: '4',target: '5', weight:1} },                 { group:'edges', data: { source: '5',target: '1', weight:1} }                ]);         cy.elements('[customgroup="'+group+'"]').layout({ name: 'circle', radius:1, startangle: 13*((math.pi)/8)});     } 

thanks help!

after hours of no progress, stepped away, built fire in fireplace, , had scotch. in moment forgot problem entirely night, solution hit me.

cytoscape has option in initialization specify layout of nodes. when implemented above, removed layout init avoid positioning nodes twice.

the proper way handle set:

layout: {         name: 'preset',         padding: 10       }, 

this allowed custom code handle desired behavior, , prevents double positioning of nodes.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -