To size a node to fit the label, cytoscape.js has the special style properties 'width': 'label' and 'height': 'label'. When used in nodes with complex shapes, like diamonds en triangles, this does not work very well. 'height': 'label' will "flatten" the shape too much, but the real problem is 'width': 'label', which will calculate the bounding box of the shape to fit around the label.
Especially with labels inside the shape ('text-valign': 'center') in shapes like triangles, the bounding box is much wider than the visible border, which makes the label flow over the border:
Is there a way to size the node enough to fit the label inside the shape? As in: do not calculate the smallest bounding box to fit the label, but resize the largest box that fits inside the shape.
Also: when a perfect width is found, is there a way to set the height to also fit the label and keep the proportions of the original shape?
