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.
Unfortunately, activation email could not send to your email. Please try again.

Adding labels to a node (V5)

Thread ID:

Created:

Updated:

Platform:

Replies:

60995 May 16,2007 10:40 AM May 25,2007 08:00 AM Windows Forms 3
loading
Tags: Diagram
ae
Asked On May 16, 2007 10:40 AM

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?

Meera Fathima [Syncfusion]
Replied On May 17, 2007 02:15 AM


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
Replied On May 17, 2007 05:28 AM

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.

Meera Fathima [Syncfusion]
Replied On May 25, 2007 08:00 AM


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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;