Closed Alexithemia closed 3 years ago
@canbax The users should be able to access number of such nodes, right?
When the nodes are collapsed, the information about the collapsed children is stored inside their data with a property named collapsedChildren
(includes both edges and nodes). So the API users can get this info easily.
Below is a sample code that prints console the number of collapsed children when a collapsed node is tapped.
cy.on('tap', 'node.cy-expand-collapse-collapsed-node', function (evt) {
let node = evt.target;
console.log('collapsed children count: ' + node.data('collapsedChildren').length);
});
Here node.data('collapsedChildren')
is a cytoscape.js collection.
In the canvas, this information can be shown in at least 2 different ways.
This information could be shown in different ways. One way is to show it like in the first image, like a badge. It can be showed like we show expand cue image.
It can also be shown on the label. Like for the image below the label could be Ministry of Commerce (2)
.
Both can be implemented inside the API or an API user can also do these without changing the API.
I did see how I would get the number from the collapsed node, and I will need to filter out only the nodes as edges are also in the collapsed children collection, adding it to the label would be easy but the badge look is what we want.
How would we go about showing that as a badge like the cue image?
That's a Cytoscape.js core issue not related to this extension. You could use background images for instance.
Would you be able to implement an option for the collapsed groups to display how many nodes are collapsed within it?
Or do you know of an easy way to achieve this? I am already using the label normally.