Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Trim long label text to match link length (Read 3190 times)
Kostya
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Aug 5th, 2014
Trim long label text to match link length
May 5th, 2023 at 11:27am
Print Post  
Hi,

Let me ask you to help me with one problem related to diagram link labels. The fact is that when the text is long, it overlaps the nodes. If it's impossible to take into account the length of the text when Arrange() to increase the link length, then I would like to at least trim the label and add an ellipsis. In doing this, I could rely on the distance between the nodes (NodeDistance), but there are also longer links, as shown in the screenshot, where there is enough space not to trim their text. So the question is, how could I trim the label based on the length of the section where it is located on the link? The goal is to increase the readability of a diagram with many long link labels.

Btw, when i use this value for LinkTextStyle

Code
Select All
Diagram.LinkTextStyle = LinkTextStyle.Rotate;
 



you may notice that the text overlaps the node, although there is still room above to fit it. Can this be fixed as well?

Thanks,
Kostya
  

long_link_label_issue.png ( 19 KB | 124 Downloads )
long_link_label_issue.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3440
Joined: Oct 19th, 2005
Re: Trim long label text to match link length
Reply #1 - May 8th, 2023 at 6:25am
Print Post  
Hi Kostya,

Do those straight-line links have more than one segments? In that situation the text still gets centered relatively to the longer segment. You could try resetting the links to single-segment Polyline ones when you detect they contain collinear control points in the middle.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Kostya
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Aug 5th, 2014
Re: Trim long label text to match link length
Reply #2 - May 8th, 2023 at 7:54am
Print Post  
Hi Slavcho,

Got it, I see what you mean about the second issue. Even though the link looks straight, it actually contains a point in the middle. And if I remove extra points, then the label is displayed centered. Thanks!

Kostya


  
Back to top
 
IP Logged
 
Kostya
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Aug 5th, 2014
Re: Trim long label text to match link length
Reply #3 - May 8th, 2023 at 11:40am
Print Post  
Hi Slavcho,

So it's clear about the shifted labels, thanks again. But could you please advise something about the main question? I mean trimming too long labels when it goes beyond it. At the same time, I would like not to cut them when there is enough space for the text. I would appreciate your help.

Kostya
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3440
Joined: Oct 19th, 2005
Re: Trim long label text to match link length
Reply #4 - May 9th, 2023 at 8:28am
Print Post  
Hi Kostya,

Set link.TextTrimming with this build -

https://mindfusion.eu/_beta/wpfdiag393.zip

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Kostya
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Aug 5th, 2014
Re: Trim long label text to match link length
Reply #5 - May 9th, 2023 at 4:29pm
Print Post  
Hi Slavcho,

Thanks much, this is what I need and works good! Let me clarify one detail. With LinkTextStyle.Rotate I get this. As you can see, the top link's text is perfectly centered, while the trimmed text, below, touches the node, leaving some space after the ellipsis. Is there any way to fix this, at least by setting the indent/padding for the label?

I may have missed something but this didn't work:
Code
Select All
link.TextPadding = new Thickness(10);
 



Thanks,
Kostya
  

long_link_label_issue2.png ( 8 KB | 130 Downloads )
long_link_label_issue2.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3440
Joined: Oct 19th, 2005
Re: Trim long label text to match link length
Reply #6 - May 11th, 2023 at 7:33am
Print Post  
Hi Kostya,

TextPadding is defined in base class but not applied by DiagramLinks at this time. New build should center the trimmed text more accurately -

https://mindfusion.eu/_beta/wpfdiag393.zip

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Kostya
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Aug 5th, 2014
Re: Trim long label text to match link length
Reply #7 - May 12th, 2023 at 11:53am
Print Post  
Thanks much Slavcho, this build works great!  Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint