Dynamic Ports sample

Hello,

I am very impressed by this example Dynamic Ports
But I struggle to adapt it into my code.
As soon as I create a new link, I get this error:

“go.js:14 Uncaught Error: getDocumentPoint:s Spot must be specific: None”

What do I need to set up in oder to make this work?
I copied the whole CustomLink part into my code. I thought it my be an issue with the nodes so I adjusted my nodeTemplate to the one from the example, but it still won’t work.
Any suggestions?

I hope you can help me!

Best regards!

You’ll need to debug that – your code is (perhaps indirectly) calling GraphObject.getDocumentPoint with go.Spot.None, which is an invalid argument.

Hello,

I am still not able to figure out, how the CustomLink works.
Where exactly is spot set?
This line is where I get the error:
var thispt = port.getDocumentPoint(this.computeSpot(from));
spot.x and spot.y are both NAN

I also don’t understand when and how often some of these functions are called:

CustomLink.prototype.computeEndSegmentLength = function(node, port, spot, from) {
CustomLink.prototype.findSidePortIndexAndCount = function(node, port) {
CustomLink.prototype.computeCurviness = function() {

While debugging I saw that the only invalid value while inside "CustomLink.prototype.computeEndSegmentLength " was spot.

Best regards!

It’s probably because you have not set the fromSpot and toSpot on each port object to specific Spot values.

You could also try to make sure almost everything works without use of the CustomLink class, and only then replace go.Link with CustomLink in your link template.

where we set the fromSpot and the toSpot is setting? i think in the nodeTemplate… this is our nodeTemplate: diagram.nodeTemplate = GOJS(go.Node, "Table", - Pastebin.com

this is our linkTemplate

the Customlink is Copied from Your " http://gojs.net/latest/samples/dynamicPorts.html2 " Code.

Best regards!

Have you set GraphLinksModel | GoJS API and GraphLinksModel | GoJS API ?

This talks about supporting multiple ports per node: GoJS Ports in Nodes-- Northwoods Software

we have insert this:

diagram.model =
                GOJS(go.GraphLinksModel,
                    {
                        linkFromPortIdProperty: "fromPort",  // required information:
                        linkToPortIdProperty: "toPort",      // identifies data property names
                    });

is there are a problem that we add the link with:
diagram.model.addLinkData();
and the nodes with:
diagram.model.addNodeData(); ?

edit: we have found the Problem. Thank you for your help!