javascript - How to give the row and col positions of a node in Cytoscap JS -


i have nodes want place in specific location within grid.

in cytoscape js defined data follows:

 nodes: [       { data: { id: '1', name: 'cytoscape1', row: '1', col:'1' } },       { data: { id: '2', name: 'cytoscape2', row: '2', col:'3' } },       { data: { id: '3', name: 'cytoscape3', row: '1', col:'3' } },       { data: { id: '4', name: 'cytoscape4', row: '1', col:'4' } }     ] 

i want use col , row data setting node position. i've added in following grid layout options graph:

layout: {     name: 'grid',     padding: 10,     rows: 4,      columns: 4,      position: function( node ){ return {node.row, node.col}; }    } 

my problem concerns function returning row , col position of node. reason piece of code doesn't work , couldn't find examples used option.

when testing in live example gives syntax error. i've tried many different means return row , col matches syntax, i'm getting more confused , nothing still worked.

what i've tried far no success example are:

position: function ( node ) { return node.row, node.col } position: function ( node ) { return node.data.row, node.data.col } position: function ( node ) { return data:row, data:col } position: function ( node ) { return {data:row, data:col}; } position: function ( node ) { return node:row, node:col } position: function ( node ) { return {node:row, node:col}; } 

and on.

update: after more searching access row , col value, know has node.data('row') , node.data('col'). stil have problem of how return row , col arguments. tried:

position: function ( node ) { return [node.data('row'), node.data('col')]; } 

however still no luck :/

ah mrintunjay! need piece together. answer is:

position: function( node ){ return {row:node.data('row'), col:node.data('col')}; }  

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -