iVis-at-Bilkent / cytoscape.js-expand-collapse

A Cytoscape.js extension to expand/collapse nodes for better management of complexity of compound graphs
MIT License
125 stars 36 forks source link

filter parent nodes which can be expanded-collapsed #21

Open mafar opened 7 years ago

mafar commented 7 years ago

Hi, Seems very useful plugin. However I wish there was a function in which one could specify which parent nodes can have expand collapse functionality and which can not (kind of filter).

For example I want to add cytoscape.js-expand-collapse control to specific parents not all. cytoscape.js-edgehandles provides such functionality with a beautiful function handleNodes which can be used as a function like this

// from https://github.com/cytoscape/cytoscape.js-edgehandles
// as string selector
handleNodes: 'node', 
// as filter function
handleNodes: function () {
    if (this.data().isExpandable) {
      // proceed with control 
      return true;
    } else {
      // no controls
      return false
    }
}
manotoor commented 5 years ago

Is this something that will still be supported?

ugurdogrusoz commented 5 years ago

@mafar @manotoor It'd be nice to have this option but currently we do not have any resources for this.

kinimesi commented 5 years ago

@manotoor you can achieve this functionality by overriding api.isExpandable and api.isCollapsible functions. The current node is provided as an argument to these functions.

https://github.com/iVis-at-Bilkent/cytoscape.js-expand-collapse/blob/8a2e4157def5613e0e477e393dc2c0720e41c032/src/index.js#L117

https://github.com/iVis-at-Bilkent/cytoscape.js-expand-collapse/blob/8a2e4157def5613e0e477e393dc2c0720e41c032/src/index.js#L122

manotoor commented 5 years ago

I set the x and y of the cue indicators to INFINITY as a workaround. I first tried removing the class from node however, that did not work