7

I wish to zoom the cyjs view to fit (nicely contain) the currently selected nodes. nodes could be selected manually, or programmatically. If only a small network neighborhood has been selected, then the zoom-in would be pretty dramatic. If distant nodes are in the selection, then the zoom in might not even be noticeable.

cy.fit(<padding>) 

works great to display the entire network within the window. But try as I may, I cannot find

cy.fitSelected()

or some functional equivalent.

Suggestions, anyone?

Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
paul shannon
  • 355
  • 5
  • 15

1 Answers1

10

It's a oneliner, as cy.fit() takes eles as its first arg: e.g. cy.fit( cy.$(':selected'), 50 ) with padding of 50

http://cytoscape.github.io/cytoscape.js/#core/viewport-manipulation/cy.fit

maxkfranz
  • 11,896
  • 1
  • 27
  • 36