Find links between groups?

Hi,
I’m trying to implement link of my diagram following:

1.No more than one link between 2 groups can be displayed when one of them is collapsed
2.A link is displayed between 2 groups if there is at least one link between two tables located in those groups
3.If two groups are expanded then links between tables should be displayed. (See next slide)

AND I am using this API group.findLinksConnected() to get link of Group. But result allways return count=0.

Please refer to this jsfiddle https://jsfiddle.net/tiepna/aL08ms24/4/
And click expand button of AdministeredItem group.( see in Handle Expand/Collapse Events)

var groupTempl = $(go.Group, “Auto”,
{
fromSpot: go.Spot.AllSides,
toSpot: go.Spot.AllSides,
isSubGraphExpanded:false
},
new go.Binding(“location”, “”, toLocation).makeTwoWay(go.Point.stringify),
$(go.Shape, “Rectangle”, { fill: “white”, stroke: “#4472C4”, strokeWidth: 2 }),
$(go.Panel, go.Panel.Vertical, // title above Placeholder
$(go.Panel, go.Panel.Horizontal, // button next to
// TextBlock
{ stretch: go.GraphObject.Horizontal, margin: 1 },
$(“SubGraphExpanderButton”,
{ alignment: go.Spot.Right, margin: 5, click: function(e, button) {
var group = button.part;
if (group instanceof go.Adornment) group = group.adornedPart;
if (!(group instanceof go.Group)) return;
var diagram = group.diagram;
if (diagram === null) return;
var cmd = diagram.commandHandler;
if (group.isSubGraphExpanded) {
if (!cmd.canCollapseSubGraph(group)) return;
} else {
if (!cmd.canExpandSubGraph(group)) return;
}
e.handled = true;

  	            	    var linksToGroupOnly = group.findLinksConnected();
  	            	    var externalLinksConnected = group.findExternalLinksConnected();
  	            	    var externalNodesConnected = group.findExternalNodesConnected();
  	            	    
  	            	    diagram.startTransaction("expand-collapse");
  	            	    if (group.isSubGraphExpanded) {
                                       
  	            	      cmd.collapseSubGraph(group);
                                          // show link between group and hide links inside group.
  	          	    	  showGroupLinkGroup(externalLinksConnected,linksToGroupOnly);     	
  	            	      
  	            	    } else {
  	            	      cmd.expandSubGraph(group);
  	            	      //hide Groups link, show links inside group
  	            	      hideGroupLinkGroup(group,externalNodesConnected,externalLinksConnected,linksToGroupOnly)
  	            	    }
  	            	    diagram.commitTransaction("expand-collapse");
  	            	  } 
  	              }),
  	            $(go.TextBlock,
  	              {
  	                alignment: go.Spot.Left,
  	                margin: 5,
  	                font: "bold 18px 'Open Sans'",
  	                stroke: "#4472C4"
  	              },
  	              new go.Binding("text", "label"))
  	          ),  // end Horizontal Panel
  		       	$(go.Panel, go.Panel.Position,
  			  	          $(go.Placeholder,{padding:5})
  			       	)
  	        )

);

OK, I’ve spent way too much time on this.

First, I should point out that your requirements, as stated, leave far too many questions unresolved. I had to make a lot of assumptions, many of which may or may not match the expectations and requirements of your app. And I am confident that the code I’m giving you leaves even more cases that I either consciously ignored or that I didn’t even think of. These kinds of requirements are filled with complications.

So here’s what I have now: Intergroup Summary Links

I originally tried to implement something in a Group.subGraphExpandedChanged event handler, but a procedural approach to doing what I think you want is far too difficult to implement. Instead I think it’s better to examine the diagram as a whole after any collapse or expand (or load or added or removed links) and figure out what you want to show. So I changed it to use “SubGraphExpanded” and “SubGraphCollapsed” DiagramEvent listeners.

Also, in this sample I chose to implement the summary links (which are “red”) as unmodeled Links – there is no link data in the GraphLinksModel corresponding to any summary link. I don’t know if that matches your needs or not. You can certainly implement them as normal links, presumably as a “Summary” category and template.

Anyway, to repeat: this can be very complicated to handle. You will need to do a lot of thinking about the possibilities.

Hi, walter.
I totally agree with you about i need spend alot of time to complete this feature.
But the question i asking here is:
I’m Using group.findLinksConnected() (Returns an iterator over all of the Links that connect with this node in either direction
).But compare result of FromNode with result of ToNode. It’s difference, at ToNode findLinksConnected allways get 0 link.

Could you check this?
Thank for your help.

Update: I’ve updated my fiddle above by add this command: console.log(group.findLinksConnected().count); Please refer to it by expand 2 group in that.

I’m sorry, but I don’t understand what you’re asking. Could you write a simple function that demonstrates what you think is a bug?

Please see this fiddle: https://jsfiddle.net/tiepna/9ww5bcvm/1/.

I’ve 2 group: TechnicalData and AdministeredItem.then i added link for them:
{
“from”: “/InformationGovernance/technicalDomain”,
“to”: “/InformationGovernance/AdministeredItem/AdministeredItem”,
“fromText”: “”,
“toText”: “”,
“label”: “”,
“category”: “Groups”,
“routing”: “go.Link.AvoidsNodes”,
“points”: “”
}

IN Group.subGraphExpandedChanged I’ve added this command :
alert("number link connected this node: " +group.findLinksConnected().count);
Then i do expand TechnicalData → i got: “number link connected this node: 1” → it’s correct
Next, i do the same thing with AdministeredItem group, then i got “number link connected this node: 0”.

Is it a bug?

Hi Walter,
That’s not a bug. I created wrong link.
Sorry for this inconvenience.