Hi @walter,
The node can have multiple ports so that I need data like below
(start node) A port is linked to another node port and
(start node) B port is not linked
is there any API like using the start node it will give data like above
Hi @walter,
The node can have multiple ports so that I need data like below
(start node) A port is linked to another node port and
(start node) B port is not linked
is there any API like using the start node it will give data like above
I don’t understand what you want. Could you please post a small screenshot or sketch of what you want and then explain your question again?
Consider two nodes, start and end node. Both start and end nodes have multiple ports. Let’s assume that the start and end node is connected by using a single port in both nodes. Now there are other free ports in the start node. Now, I’m expecting a function that will return the ports used, nodes connected to it, and the free port present.
For example, if I send a start node, I need to get information regarding the nodes connected (Along with port details) and also free ports.
As shown in the above image, I’ll be passing a start node and am expecting an output similar to this. Kindly, give your suggestion.
Output:
{
port A linked to X port of End node
port B - no link
}
<!DOCTYPE html>
<html>
<head>
<title>Minimal GoJS Sample</title>
<!-- Copyright 1998-2021 by Northwoods Software Corporation. -->
</head>
<body>
<div id="myDiagramDiv" style="border: solid 1px black; width:100%; height:600px"></div>
<script src="https://unpkg.com/gojs"></script>
<script id="code">
function init() {
const $ = go.GraphObject.make;
myDiagram =
$(go.Diagram, "myDiagramDiv",
{
"undoManager.isEnabled": true
});
function makePort(id, spot) {
return $(go.Shape,
{ portId: id, alignment: spot,
fromLinkable: true, toLinkable: true,
width: 8, height: 8, fill: "gray", strokeWidth: 0 });
}
myDiagram.nodeTemplate =
$(go.Node, "Auto",
{
click: (e, node) => {
console.log(`${node.key}: ${node.data.text}`)
node.ports.each(p => {
console.log(` "${p.portId}" ${node.findLinksConnected(p.portId).count}`)
node.findLinksConnected(p.portId).each(l => {
console.log(` ${l.fromNode.key},${l.fromPort.portId} --> ${l.toNode.key},${l.toPort.portId}`)
});
});
}
},
$(go.Shape,
{ fill: "white", portId: "", fromLinkable: true, toLinkable: true, cursor: "pointer" },
new go.Binding("fill", "color")),
$(go.TextBlock,
{ margin: 12, editable: true },
new go.Binding("text").makeTwoWay()),
makePort("T", go.Spot.Top),
makePort("R", go.Spot.Right),
makePort("B", go.Spot.Bottom),
makePort("L", go.Spot.Left)
);
myDiagram.model = $(go.GraphLinksModel,
{
linkFromPortIdProperty: "fpid",
linkToPortIdProperty: "tpid",
nodeDataArray:
[
{ key: 1, text: "Alpha", color: "lightblue" },
{ key: 2, text: "Beta", color: "orange" },
{ key: 3, text: "Gamma", color: "lightgreen" },
{ key: 4, text: "Delta", color: "pink" }
],
linkDataArray:
[
{ from: 1, fpid: "R", to: 2, tpid: "L" },
{ from: 1, fpid: "B", to: 3, tpid: "T" },
]
});
}
window.addEventListener('DOMContentLoaded', init);
</script>
</body>
</html>