We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Adding labels to a node (V5)

I have a problem postionig 2 labels inside a node (Polygon node). I would like to have 2 line of text with different style one below another.
Something like this in the pseudo code:

text1


text2


But adding labels seems to make them overlap. When using OffsetX/OffsetY I can't get good results. I can't position correctly second label.

Could you help me with this problem?

3 Replies

MF Meera Fathima Syncfusion Team May 17, 2007 06:15 AM UTC


Hi Mike,

Thanks for using Syncfusion Essential Diagram.

I have tested this behavior(adding two labels of different styles in a polygon node) in the Diagram Builder sample( v5.1.0.51 version) at runtime. And it is working as expected. Please see the image below.

http://websamples.syncfusion.com/samples/Diagram.Windows/F60995- Image/main.htm

I have also tried with programmatic creation and attached the sample. Please download the sample from the following link - http://websamples.syncfusion.com/samples/Diagram.Windows/F60995/main.htm

Please refer the sample's CreateCustomPolygon() method that shows the adding of labels into the polygon programmatically. And let me know if you still has any problem with this.

Thanks,
Meera.



AE ae May 17, 2007 09:28 AM UTC

It seem that documentation for Lable.OffsetX/Y is misleading. It says:

"Specifies AnchoringPrimitive offset in _percents_ relative to its container's width from container's top left point. (inherited from AnchoringPrimitive)"

Actauly it is not percent but pixels. So having text centered on X axis it must be calculated this way:
label.OffsetX = node.Size.Width / 2;

In your example code it was hard coded value that fit in actual node size label.OffsetX = 40 that didnt seem to work when you modify the size of node.

I had expected value of 50 (%) just to work.


MF Meera Fathima Syncfusion Team May 25, 2007 12:00 PM UTC


Hello Mike,

Sorry for the delay in getting back to you on this query.

Regarding your query, yes you are right about the label offset calculations. And Diagram follows the same concept. (i.e.) If Label.Position is set to custom value, you need to specify the Label.OffsetX and OffsetY values explicitly. And for all other values of Label.Position property such as Center,TopLeft etc., it will be calculated automatically. Please look into the Diagram.Base\Src\Entities\AnchoringPrimitive class GetPosition() method. The label's offset value is calculated based on its position value.

If your intension is to set the label's offset value and to maintain it while resizing the node(Label container), you can do this by raising the Diagram.Model.EventSink.SizeChanged event method and providing the suitable code implementation within this method.

I hope the informations are helpful. Please let me know if you have any more queries. We will be glad to assist.

Thanks,
Meera.

Loader.
Live Chat Icon For mobile
Up arrow icon