Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Draw a customize link between to node. (Read 4135 times)
Ankur shah
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Mar 16th, 2017
Draw a customize link between to node.
Oct 30th, 2018 at 7:45am
Print Post  
As you see the attached pic i need draw a custom from container 1 to container 2 ( which can be any where inside my diagram) I need to give user flexibility to choose the link from nodelist view first click on container is it's origin and second click is its destination. We have 3 to 4 kinds of links.

In the attached pic Arrow is shape node and we are not able connect to another container node.
Can you please suggest something what should i try to achieve this kind of functionality?
  

link.PNG ( 24 KB | 99 Downloads )
link.PNG
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Draw a customize link between to node.
Reply #1 - Oct 30th, 2018 at 9:47am
Print Post  
Try this approach -
https://mindfusion.eu/blog/create-diagram-connectors-using-drag-and-drop/

The example is for C# but similar APIs should be available in JavaScript version as well.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Ankur shah
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Mar 16th, 2017
Re: Draw a customize link between to node.
Reply #2 - Oct 30th, 2018 at 10:18am
Print Post  
I was checking that example but could not find similar api in java script.
  
Back to top
 
IP Logged
 
Ankur shah
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Mar 16th, 2017
Re: Draw a customize link between to node.
Reply #3 - Oct 31st, 2018 at 6:11am
Print Post  
I am trying to draw connector using below code but could not find shape class accepting arguments it is only having default constructor. Even i could not find an api equivalent LineTemplate.
Code (Javascript)
Select All
let connectorShape = new MindFusion.Diagramming.Shape(null,
            new Array(new LineTemplate(10, 10, 10, 50),
                new LineTemplate(10, 50, 90, 50),
                new LineTemplate(90, 50, 90, 90)),
            null,
            FillRule.Nonzero, "Connector");
 

  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Draw a customize link between to node.
Reply #4 - Oct 31st, 2018 at 9:11am
Print Post  
Hi,

To create the custom shape you can use the ShapeDesigner.exe tool (provided with the package) to save shapes you want to use and load them via the ShapeLibrary API. Or you can use the following code to create the shape definitions directly in code:

Code (Javascript)
Select All
MindFusion.Diagramming.Shape.registerDefaultShape(
    new MindFusion.Diagramming.Shape({ id: "Connector", outline: "", decoration: "M10,10 L10,50 L90,50 L90,90" })); 



Then you can use this shape like all the other predefined ones:
Code (Javascript)
Select All
var shape = MindFusion.Diagramming.Shape.fromId("Connector"); 


Regards,
Lyubo
  
Back to top
 
IP Logged
 
Ankur shah
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Mar 16th, 2017
Re: Draw a customize link between to node.
Reply #5 - Oct 31st, 2018 at 10:49am
Print Post  
Hi

I am not able find any api with name registerdefaultshape.
Please have a look the library i am having.
  

index_d_ts.zip ( 34 KB | 198 Downloads )
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Draw a customize link between to node.
Reply #6 - Oct 31st, 2018 at 1:09pm
Print Post  
Hi,

Indeed this method and the ShapeLibrary class are not part of the typescript definitions file at the moment, we will add them in a later release.

To add your custom shape, use the ShapeDesigner.exe tool and save a xml library with it. You can then assign that xml library file to the Diagram/NodeListView ShapeLibraryLocation property to use in your project.

If you want to use the svg-like path syntax to define your shapes, you can add the registerDefaultShape and the Shape constructor to your local definitions file as a workaround:
Code (Javascript)
Select All
//jsdiag.d.ts

//...

class Shape
{
    // ...
   constructor(params?: any)
   static registerDefaultShape(shape: Shape): void;
}

//... 



Regards,
Lyubo
  
Back to top
 
IP Logged
 
Ankur shah
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Mar 16th, 2017
Re: Draw a customize link between to node.
Reply #7 - Nov 1st, 2018 at 7:32am
Print Post  
Can you please let us know by when we can get a latest version jsdiag.d.ts ?
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Draw a customize link between to node.
Reply #8 - Nov 5th, 2018 at 10:27am
Print Post  
Hi,

Please find the updated definitions files attached to this post. It won't be necessary to call the registerDefaultShapeMethod to use the shape. Calling the constructor is enough:
Code (Javascript)
Select All
var shape = new MindFusion.Diagramming.Shape({ id: "Connector", outline: "", decoration: "M10,10 L10,50 L90,50 L90,90" });  



Regards,
Lyubo
« Last Edit: Nov 20th, 2018 at 7:28am by Lyubo »  

jsdiag_001.zip ( 42 KB | 232 Downloads )
Back to top
 
IP Logged
 
Ankur shah
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Mar 16th, 2017
Re: Draw a customize link between to node.
Reply #9 - Nov 20th, 2018 at 5:40am
Print Post  
As suggested by you i am trying to add the shape node in a node list view. Got the below attached error.
  

MINFUSION_err.PNG ( 15 KB | 99 Downloads )
MINFUSION_err.PNG
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Draw a customize link between to node.
Reply #10 - Nov 20th, 2018 at 7:07am
Print Post  
Hi,

Please, post here the shape definition you're trying to use, so that we can investigate. If you're using only decoration elements, make sure the definition includes an empty string outline parameter too, like in the above example.

Also, just noticed that the example above has one closing parenthesis than needed and that will cause a syntax error. I've modified the example to be correct now.

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