Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Cannot position text / restrict to songle line (Read 686 times)
Derek Brennan
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 1
Joined: Feb 28th, 2023
Cannot position text / restrict to songle line
Feb 28th, 2023 at 8:27pm
Print Post  
I am using Mindfusion diagramming (Javascript). As part of a feature I need the ability to do a few things, none of which I can work out how to do.

1.      The ability to restrict the text inside the node to a single line. Currently it wraps if too long. I can’t see any way to set the style to something like “white-space: nowrap; overflow: hidden; text-overflow: ellipsis;”

2.      I would like the ability to set a top margin, so that even if text is multi-line, there is a space in the upper part of the node that remains empty.

3. If I can restrict to a single line, can I set the vertical alignment? I've tried the likes of..

diagramNode.setStyle('white-space: nowrap; overflow: hidden; text-overflow: ellipsis;');
diagramNode.setStyle('margin-top: 10px');
diagramNode.setTextPadding('1, 1, 1, 5');
diagramNode.setTextPadding(1, 1, 1, 5);

I may not be calling these correctly, its difficult to know as there is a severe lack of code samples.

Any help appreciated.

Derek.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Cannot position text / restrict to songle line
Reply #1 - Mar 1st, 2023 at 5:59am
Print Post  
You could use html-templated ControlNodes to let the browser render text, along with CSS styling. These don't participate in diagram's Z order though, so you can't place other nodes or links on top.

Otherwise the diagram's own text layout always wraps to multiple lines at this time. You can override its wrapping method as shown here -
https://mindfusion.eu/Forum/YaBB.pl?num=1415114615/3#3

Setting text padding is done via Thickness object -

Code
Select All
node.textPadding = new MindFusion.Drawing.Thickness(1, 1, 1, 1);
 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Cannot position text / restrict to songle line
Reply #2 - Mar 1st, 2023 at 12:08pm
Print Post  
Linked method has a new parameter, updated code for current version is -

Code
Select All
var Text = MindFusion.Drawing.Text;
var originalGetLines = Text.prototype.getLines;
Text.prototype.getLines = function (context, rect)
{
	var wrappedLines = originalGetLines.apply(this, [context, rect]);
	if (wrappedLines.length < 2)
		return wrappedLines;

	var line = wrappedLines[0];
	line += " ...";
	this.lines = [line];
	return this.lines;
}; 

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint