cytoscape / cytoscape.js

Graph theory (network) library for visualisation and analysis
https://js.cytoscape.org
MIT License
10.09k stars 1.64k forks source link

Ability to specify size of parent nodes #1051

Closed dabobert closed 7 years ago

dabobert commented 9 years ago

Even though i try to specify the size of parent nodes, the width and height attributes always seems to be ignored. I would find it beneficial to limit the space that parent nodes and their children take up on the canvas

maxkfranz commented 9 years ago

This may be possible to set as an option in particular layouts, but it's probably not possible in general with all the features that the API supports.

For example, some layouts only apply to noncompound nodes. So, all the child nodes get positioned according to the layout algorithm (e.g. arbor or grid). A compound parent has its dimensions set automatically based on its children. If a restriction is set on compound dimensions, there is a contradiction.

It would be possible to have layouts (like the upcoming CoSE2) have support for limiting compound node sizes -- but even then this is more of just a hint rather than a hard and fast restriction. Even within a layout, restricting compound size can create contradictions. Consider avoiding overlap. The compound may not have enough space to avoid its children from overlapping.

dabobert commented 9 years ago

honestly a hint would be amazing. I understand that if a person were to define too little space for a compound nodes and its child nodes, it would have to "bust out" of the size originally designed

And if this could be included in an upcoming release that would be amazing.

ugurdogrusoz commented 8 years ago

Limiting compound node sizes is not straightforward at all. Any particular reason that you'd like to limit a compound node's size? Can you share with us some examples where the layout inside compounds are not to your satisfaction? Have you tried increasing gravity if you think layout produces compound nodes that are too large? Also, if your compounds typically include disconnected nodes, you should turn tiling on.

ugurdogrusoz commented 8 years ago

I think a layout algorithm's treatment of compound sizes is independent of whether or not the core allows resize of compounds. When you call layout, you should be ready to / expect to see node positions and compound node dimensions change! I think there should be an option at the core for compounds for auto resizing of compounds. I would make it true by default (current behavior). If false, however, I would allow compounds to be resized arbitrarily (independent of their children). We might want to restrict the geometry of the compounds in such a way that a compound is always "bigger" than its children's bounding rectangle (+paddings). There is no reason to disallow a compound to be "bigger" than its content, otherwise. The behavior about moving children as a compound moves, and adjusting compound dimensions to include all children when children are moved as necessary should be kept of course. In addition, when the user tries to resize a compound to be smaller than its content, it should be adjusted to be at least as big as its content, regardless of the current value of this option.

ugurdogrusoz commented 7 years ago

@dabobert Now it's possible to size compounds to be bigger than their children's bounds using the options specified under "Compound parent sizing" in Cytoscape.js documentation. This is a feature outside a layout. For a layout to support this is a separate issue; in other words, layout might change any specified size for a compound.

kunalganglani commented 7 years ago

I want to use dagre layout along with an option to make the child nodes have vertical alignment and compound nodes a fixed height and width. Is this possible?

rbowers02 commented 1 year ago

@kunalganglani Just curious were you able to accomplish this? I was looking to do the same thing I have 20 nodes inside a parent and I would like to be able to set max width on that parent and force a 4x5 layout inside that parent.