I have implemented the OrgChartExtras diagram on my app.
I’m trying to create the “secondary” links (orange and green) and I succesfully did it as prototype with a HTML form and a Javascript Function:
``
function addNewLinkType(text) {
var node = myDiagram.selection.first();
// maxSelectionCount = 1, so there can only be one Part in this collection
var data = node.data;
if (node instanceof go.Node && data !== null) {
var model = myDiagram.model;
model.startTransaction("modified link" );
var type = document.getElementById("type").value;
var who = document.getElementById("who").value;
var text = document.getElementById("linktext").value;
myDiagram.model.addLinkData({ from: node.data.key, to: who, category: type, text: text});
model.commitTransaction("modified link");
//document.getElementById("mySavedModel").value = myDiagram.model.toJson();
myDiagram.isModified = false;
}
}
But I can’t find the way how I can add Orange and green links using drag&drop.
I suspect that the problem is that your diagram has Diagram.validCycle set to some value to limit the user to only having tree-structured graphs. Such link validity checks only consider Links that are Link.isTreeLink.
The problem is that if you set the LinkingTool.archetypeLinkData to some data that specifies a link category whose corresponding link template has Link.isTreeLink set to false, the LinkingTool doesn’t realize that it would be OK to draw such a link in a non-tree relationship. That’s because LinkingTool.isValidLink doesn’t know whether any future to-be-drawn link will be Link.isTreeLink or not – it just assumed that the not-yet-created link will be isTreeLink.
We have improved the link validity checking in version 1.8.7, which is available now in beta: GoJS Change Log. Please try it and see if users can now draw non-isTreeLink links by setting LinkingTool.archetypeLinkData to specify a link template that has Link.isTreeLink set to false.