Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Text goes out of the shape if content is very long (Read 1645 times)
Kiran B
Full Member
***
Offline


I Love MindFusion!

Posts: 102
Joined: Apr 19th, 2013
Text goes out of the shape if content is very long
Apr 29th, 2013 at 9:21am
Print Post  
Hi,

The text entered in the shape node is going outside the shape and it looks really ugly. Is there any way to show the text within the shape? If the text is too long show only the text which can be shown inside the diagram, the rest can be trimmed off. Is there any hack for this?

Thanks
Kiran B
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Text goes out of the shape if content is very long
Reply #1 - Apr 29th, 2013 at 11:13am
Print Post  
Hi,

You could trim the text by overriding our wrapLine function:

Code
Select All
var Text = MindFusion.Drawing.Text;
var originalWrap = Text.wrapLine;
Text.wrapLine = function (context, text, maxWidth, lines)
{
	originalWrap.apply(this, [context, text, maxWidth, lines]);
	for (var i = 0; i < lines.length; i++)
	{
		var line = lines[i];
		while (context.measureText(line).width > maxWidth)
		{
			line = line.substring(0, line.length - 1);
		}
		lines[i] = line;
	}
}; 



With this version you could also call node.resizeToFitText(FitSize.KeepRatio) to make the node large enough to fit its text:
https://mindfusion.eu/_beta/MvcDiagram15.zip

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint