Hello!
I am evaluating GoJS by trying to recreate some in-house stuff using code based on the Dynamic Ports sample, which is the closest to our use case.
Easiest way for me to do this is to put the code into our React app on a separate page, so I’ve done exactly that. I merged the React sample with the Dynamic Ports sample, which required a few adaptions but was straight forward. Migrating our objects into nodeDataArray
was very easy using a few new go.Binding
s.
But when I got the node ports created I see my sample is not behaving as the Dynamic Ports sample. It looks like it uses the default link instead of the CustomLink
in the code. I can drag a new link from one port to another, and it snaps to the ports just fine. But when I release the mouse the created link does not go between the ports I pointed to, it goes go from node center to node center.
There are three pieces of code that are involved AFAICS:
...
myDiagram.linkTemplate = $( CustomLink, // defined below
{
routing: go.Link.AvoidsNodes,
corner: 4,
curve: go.Link.JumpGap,
reshapable: true,
resegmentable: true,
relinkableFrom: true,
relinkableTo: true
},
new go.Binding( "points" ).makeTwoWay(),
$( go.Shape, { stroke: "#2F4F4F", strokeWidth: 2 } )
)
...
function CustomLink() {
go.Link.call( this )
}
go.Diagram.inherit( CustomLink, go.Link )
...
I have verified that CustomLink() itself gets called when the diagram is created, but then something is missing in the inheritance because findSidePortIndexAndCount
is never called when I create links.
Any tips on how to get this hooked up right would be helpful!
(Full code at https://pastebin.com/DNgNpWkU)