Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to Load Style String (Read 1509 times)
alukes
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 61
Joined: Jul 1st, 2011
How to Load Style String
Jun 23rd, 2021 at 11:35pm
Print Post  
When I execute this statement, item.getStyle();

I get this result.

"{"fontName":"Courier New","fontSize":"6"}"


When I run the following

let decodeStyle = decodeURI("{"fontName":"Courier New","fontSize":"6"}");
let styleObject = JSON.parse(decodeStyle);
node.setStyle(styleObject);

I get this error:

Uncaught TypeError: style.getFontName is not a function
at mdiag.ShapeNode.getEffectiveFontName (eval at <anonymous> (MindFusion.Diagramming.js:1), <anonymous>:1:194415)
at mdiag.ShapeNode.getEffectiveFont (eval at <anonymous> (MindFusion.Diagramming.js:1), <anonymous>:1:194213)
at mdiag.ShapeNode.updateCanvasElements (eval at <anonymous> (MindFusion.Diagramming.js:1), <anonymous>:1:733304)
at mdiag.ShapeNode.getOutline (eval at <anonymous> (MindFusion.Diagramming.js:1), <anonymous>:1:735702)
at mdiag.ShapeNode.getNearestBorderPoint (eval at <anonymous> (MindFusion.Diagramming.js:1), <anonymous>:1:223836)
at mdiag.ShapeNode.getNearestAnchor (eval at <anonymous> (MindFusion.Diagramming.js:1), <anonymous>:1:216283)
at mdiag.ShapeNode.getAnchor (eval at <anonymous> (MindFusion.Diagramming.js:1), <anonymous>:1:215604)
at mdiag.DiagramLink.validateParams (eval at <anonymous> (MindFusion.Diagramming.js:1), <anonymous>:1:480062)
at new mdiag.DiagramLink (eval at <anonymous> (MindFusion.Diagramming.js:1), <anonymous>:1:454067)
at mdiag.Factory.Factory.createDiagramLink (eval at <anonymous> (MindFusion.Diagramming.js:1), <anonymous>:1:547623)




What am I missing? Thanks
« Last Edit: Jun 24th, 2021 at 4:50am by alukes »  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: How to Load Style String
Reply #1 - Jun 24th, 2021 at 5:55am
Print Post  
Hi,

setStyle expects an instance of the Style class -

Code
Select All
let decodeStyle = decodeURI('{"fontName":"Courier New","fontSize":"6"}');
let styleObject = JSON.parse(decodeStyle);
var style = new MindFusion.Diagramming.Style();
style.fromJson(styleObject);
node.setStyle(style);
 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint