labeling orthogonal and polyline links
How do I position the label for an orthogonal or polyline link so that it sits in the center of one of the line segments (preferable one that is horizontal, if it exists) instead of in the center of the link's bounding box?
SIGN IN To post a reply.
3 Replies
PM
Pandi Murugan A
Syncfusion Team
August 20, 2010 01:01 PM UTC
Hi Jan,
Thank you for using Syncfusion Products.
We suggest you to use Syncfusion Diagram Label’s property ‘Position’ to position the label for nodes/connectors in your diagram. By default its value is Center. It has some other values TopLeft, TopRight, TopCenter, BottomLeft, BottomRight, BottomCenter, Custom, MiddleLeft, and MiddleRight.
Please refer the following code snippet.
We created a sample for your reference. Please refer the sample below.
Forum_LabelPosition-1395112399.zip
Please let me know if you have any concerns.
Regards,
Pandi Murugan A.
Thank you for using Syncfusion Products.
We suggest you to use Syncfusion Diagram Label’s property ‘Position’ to position the label for nodes/connectors in your diagram. By default its value is Center. It has some other values TopLeft, TopRight, TopCenter, BottomLeft, BottomRight, BottomCenter, Custom, MiddleLeft, and MiddleRight.
Please refer the following code snippet.
[C#]
Syncfusion.Windows.Forms.Diagram.Label lbl = new Syncfusion.Windows.Forms.Diagram.Label();
lbl.Container = connector;
lbl.Text = "Connector";
lbl.Position = Position.BottomCenter;
lbl.UpdatePosition = true;
connector.Labels.Add(lbl);
We created a sample for your reference. Please refer the sample below.
Forum_LabelPosition-1395112399.zip
Please let me know if you have any concerns.
Regards,
Pandi Murugan A.
AD
Administrator
Syncfusion Team
August 20, 2010 05:34 PM UTC
I was already familiar with the Position property. What I was trying to ask was: How do I test the link so as to be able to determine which position will be the best position for placing the label. (ie; if the orthogonal link is shaped like an 'L', you might want the label at CenterBottom. If it is shaped like an upside-down 'L', you might want it at the CenterTop.)
Sorry I didn't describe the question more clearly.
v/r
Jan
Sorry I didn't describe the question more clearly.
v/r
Jan
PM
Pandi Murugan A
Syncfusion Team
August 21, 2010 08:25 AM UTC
Hi Jan,
Thank you for your update.
Orthogonal Connector has HeadEndPoint and TailEndPoint property.We suggest you to use HeadEndPoint's and TailEndPoint's property Location.Y to test the link so as to be able to determine which position will be the best position for placing the label. You have to position the connector’s label after adding the connector to diagram.
Please refer the following code snippet.
In this code the connector’s Label (lbl) is positioned at TopCenter of connector. After interchanging the Y coordinates of ellipse and rectangle Label will be positioned at BottomCenter.
Please refer the sample below.
Forum_LabelPosition_Modified1793598720.zip
Please let me know if you have any concerns.
Regards,
Pandi Murugan A
Thank you for your update.
Orthogonal Connector has HeadEndPoint and TailEndPoint property.We suggest you to use HeadEndPoint's and TailEndPoint's property Location.Y to test the link so as to be able to determine which position will be the best position for placing the label. You have to position the connector’s label after adding the connector to diagram.
Please refer the following code snippet.
[C#]
Ellipse ellipse = new Syncfusion.Windows.Forms.Diagram.Ellipse(10, 100, 110, 70);
Syncfusion.Windows.Forms.Diagram.Rectangle rectangle = new Syncfusion.Windows.Forms.Diagram.Rectangle(300, 10, 50, 80);
OrthogonalConnector connector = new OrthogonalConnector(PointF.Empty, new PointF(0, 10));
connector.HeadDecorator.DecoratorShape = DecoratorShape.Filled45Arrow;
connector.LineStyle.LineColor = Color.Black;
this.diagram1.Model.AppendChild(ellipse);
this.diagram1.Model.AppendChild(rectangle);
ellipse.CentralPort.TryConnect(connector.HeadEndPoint);
rectangle.CentralPort.TryConnect(connector.TailEndPoint);
Syncfusion.Windows.Forms.Diagram.Label lbl = new Syncfusion.Windows.Forms.Diagram.Label();
lbl.Container = connector;
lbl.Text = "Connector";
lbl.UpdatePosition = true;
connector.Labels.Add(lbl);
this.diagram1.Model.AppendChild(connector);
if (connector.HeadEndPoint.Location.Y < connector.TailEndPoint.Location.Y)
lbl.Position = Position.BottomCenter;
else
lbl.Position = Position.TopCenter;
In this code the connector’s Label (lbl) is positioned at TopCenter of connector. After interchanging the Y coordinates of ellipse and rectangle Label will be positioned at BottomCenter.
Please refer the sample below.
Forum_LabelPosition_Modified1793598720.zip
Please let me know if you have any concerns.
Regards,
Pandi Murugan A
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
AD Administrator
- Aug 15, 2010 02:21 PM UTC
- Aug 21, 2010 08:25 AM UTC