Possible to truncate labels automatically?
Hi,
I was wondering if I could set Labels on nodes to automatically truncate or get them to not draw outside bounds of parent container (i.e. the node). Ideally i'd be able to put in a '...' for the truncation.
Any help would be appreciated.
Thanks,
John
I was wondering if I could set Labels on nodes to automatically truncate or get them to not draw outside bounds of parent container (i.e. the node). Ideally i'd be able to put in a '...' for the truncation.
Any help would be appreciated.
Thanks,
John
SIGN IN To post a reply.
3 Replies
AA
Amsath Ali M
Syncfusion Team
October 14, 2011 04:39 AM UTC
Hi Johnathan,
Thanks for using Syncfusion products.
Currently, we don’t have support for ‘Wrapping the text of label'. This has been already confirmed as a Feature Request. For this, please create a DT incident for your query so that we can update the status or patch for the feature.
You can create the DT incident from the following link.
http://www.syncfusion.com/account/dashboard
In the interests of maintaining confidentiality, we have a policy of not sharing patches or otherwise proprietary customer specific information in the public Forum.
In the meanwhile, you can use the ‘TextNode’ instead of ‘Label’ inside a node and then grouped it together. Since the label has some limitations in terms of usage of its properties, TextNode was implemented considering to overcome these limitations and also we have 'WrapText' property for TextNode.
Please refer the below code snippet:
[C#]
Syncfusion.Windows.Forms.Diagram.Rectangle rect1 = new Syncfusion.Windows.Forms.Diagram.Rectangle(300, 100, 90, 50);
Syncfusion.Windows.Forms.Diagram.TextNode tnode = new TextNode('This is an example for TextNode in Rectangle', new RectangleF(20, 0, 50, 50));
tnode.WrapText = true;
tnode.LineStyle.LineColor = Color.Transparent;
tnode.HorizontalAlignment = StringAlignment.Center;
tnode.VerticalAlignment = StringAlignment.Center;
//group the textnode and rectangle
Group grp = new Group();
grp.AppendChild(rect1);
grp.AppendChild(tnode);
diagram1.Model.AppendChild(grp);
For your convenience, we have created a simple sample to achieve your requirement.
Please try the below sample and let us know if you have any queries.
INc 85456- Text wrap-73969985.zip
Regards,
Amsath Ali. M
Thanks for using Syncfusion products.
Currently, we don’t have support for ‘Wrapping the text of label'. This has been already confirmed as a Feature Request. For this, please create a DT incident for your query so that we can update the status or patch for the feature.
You can create the DT incident from the following link.
http://www.syncfusion.com/account/dashboard
In the interests of maintaining confidentiality, we have a policy of not sharing patches or otherwise proprietary customer specific information in the public Forum.
In the meanwhile, you can use the ‘TextNode’ instead of ‘Label’ inside a node and then grouped it together. Since the label has some limitations in terms of usage of its properties, TextNode was implemented considering to overcome these limitations and also we have 'WrapText' property for TextNode.
Please refer the below code snippet:
[C#]
Syncfusion.Windows.Forms.Diagram.Rectangle rect1 = new Syncfusion.Windows.Forms.Diagram.Rectangle(300, 100, 90, 50);
Syncfusion.Windows.Forms.Diagram.TextNode tnode = new TextNode('This is an example for TextNode in Rectangle', new RectangleF(20, 0, 50, 50));
tnode.WrapText = true;
tnode.LineStyle.LineColor = Color.Transparent;
tnode.HorizontalAlignment = StringAlignment.Center;
tnode.VerticalAlignment = StringAlignment.Center;
//group the textnode and rectangle
Group grp = new Group();
grp.AppendChild(rect1);
grp.AppendChild(tnode);
diagram1.Model.AppendChild(grp);
For your convenience, we have created a simple sample to achieve your requirement.
Please try the below sample and let us know if you have any queries.
INc 85456- Text wrap-73969985.zip
Regards,
Amsath Ali. M
JT
Johnathan Tunnicliffe
October 14, 2011 09:22 AM UTC
Is there an option to truncate the text rather than wrap the text? I have 6 labels on my node positioned quite specifically, is the same thing achievable with the TextNode inside my other node?
By truncate I mean this:
Original Text:
This is some long text that i would like to truncate
Truncated (this is what i would like to achieve):
This is some long text ...
Wrapped:
This is some long text that
i would like to truncate
By truncate I mean this:
Original Text:
This is some long text that i would like to truncate
Truncated (this is what i would like to achieve):
This is some long text ...
Wrapped:
This is some long text that
i would like to truncate
PM
Pandi Murugan A
Syncfusion Team
October 17, 2011 10:36 AM UTC
Hi Johnathan,
Thanks for the update.
You can adjust the Label's size to achieve your requirement. Please refer the below code snippet.
Here is the sample for your reference.
10130423672985.zip
Please let me know if any concerns.
Regards,
Pandi Murugan A
Thanks for the update.
You can adjust the Label's size to achieve your requirement. Please refer the below code snippet.
[C#]
Ellipse ellipse = new Ellipse(0, 0, 100, 100);
Syncfusion.Windows.Forms.Diagram.Label lbl = new Syncfusion.Windows.Forms.Diagram.Label();
lbl.Text = "This is long text";
lbl.Size = new SizeF(30, 15);
ellipse.Labels.Add(lbl);
diagram1.Model.AppendChild(ellipse);
Here is the sample for your reference.
10130423672985.zip
Please let me know if any concerns.
Regards,
Pandi Murugan A
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
JT Johnathan Tunnicliffe
- Oct 13, 2011 11:27 AM UTC
- Oct 17, 2011 10:36 AM UTC