Hello! I am attempting to position a numbered circle below the text labels of my nodes. Here’s an image example:
My thought process is that I’d get the height of the textblock underneath our nodes and with a binding, monitor the text itself to then calculate where the numbered circle needs to be located (I’ve attached code of this below). The problem that I am encountering is that our labels can be max 2 lines (as demonstrated on Node C), and I’m struggling to find a gojs utility that’ll give me the height of the textblock itself. For example, Node B’s textblock will have a height of “12”, but Node C also reports back a height of “12” despite being double the height. NaturalBounds, measuredBounds, actualBounds, isMultiLine, lineCount, and lineHeight all report back the same dimensions for both node’s textblocks. Is there perhaps something I’m missing in the docs that’s meant to handle this? Or is there an easier approach to my end goal of just floating the numbered circle below the text?
Thanks!
public static NumberedBubble(): Panel {
return GO(
Panel,
'Spot',
{
alignment: new Spot(0.5, 1, 0, -25),
},
new Binding('alignment', 'name', (_: string, node: any) => {
const textBlock = node.part.findObject('LABEL'); // returns the textblock itself
return new Spot(0.5, 1, 0, 30 + (textBlock.lineCount > 1 ? 25 : 0));
}),
GO(Shape, 'CircularRectangleBorder', {
width: 15,
height: 15,
fill: 'transparent',
stroke: 'black',
}),
GO(
TextBlock,
{
width: 14,
height: 14,
textAlign: 'center',
stroke: 'black',
pickable: false,
text: '5000',
},
new Binding('text', 'order')
)
);
}
}
