when I drag a node from diagram with self link line, and drop to other diagram then link will drop on wrong position.
This is surprising. Do you experience that problem when running Two Diagrams ?
Can you tell us how to reproduce the problem? Does it happen in your app when running on different platforms or in different browsers? What version of GoJS are you using in your app?
What DiagramEvent listeners have you defined and what do they do? What Diagram or DraggingTool properties have you set and to what values? Have you overridden any methods on any class?
I use new version on google chrome, GoJS-1-7-7-…
this is my template
$go(go.Node, “Spot”, {resizable: true, contextMenu: myContextMenu,
resizeObjectName: “BODY”, locationObjectName: “BODY”, selectionObjectName: “BODY”}, //{selectionAdorned: false},
new go.Binding(“location”, “loc”, go.Point.parse).makeTwoWay(go.Point.stringify),
new go.Binding(“zOrder”).makeTwoWay(),
$go(go.Panel, “Auto”,
// define the node’s outer shape, which will surround the TextBlock
$go(go.Shape,
{
name:“BODY”,
strokeWidth: 1.5,
portId: “”, // this Shape is the Node’s port, not the whole Node
},
new go.Binding(“parameter1”, “param1”).makeTwoWay(),
new go.Binding(“figure”, “fig”).makeTwoWay(),
new go.Binding(“fill”, “color”).makeTwoWay(),
new go.Binding(“desiredSize”, “size”, go.Size.parse).makeTwoWay(go.Size.stringify)
),
$go(go.TextBlock, {
font: “bold 11pt helvetica, bold arial, sans-serif”,
editable: true // editing the text automatically updates the model data
},
new go.Binding(“text”).makeTwoWay(),
new go.Binding(“margin”).makeTwoWay()
)
))
I will research it please wait.
The template probably does not matter. I’m suspicious that it depends on the browser or on other unexpected CSS styling that you may have done on elements inside the Diagram’s HTML DIV element. It is important that you not modify the contents of that DIV in any manner.
it only happen when self link. IE11 also same. let me look my code more carefully.
when copy and paste it not happen.
I test it out it may be because of curve: go.Link.Bezier, have two point.
I just modify the State Chart sample make it happen. see. Please can you fix it ?
OK, what’s going on is in that sample, the model remembers the link points on each link data object, as the data.points
property, an Array.
If you do not want that functionality, just remove the Binding on Link.points, and your reported problem goes away.
But if you do want the model to remember the routes of the Links, you want to keep that Binding. This is usually the case only when the user is able to reshape the routes of Links, because Link.reshapable is true. Otherwise there would be no need to remember any link routes.
When the user selects some Nodes and some Links (possibly with manually reshaped routes), when the user does a copy-and-paste or a drag-and-drop-copy, it will try to remember those custom link routes. But note that they may be lost if the copied Nodes change size or their relative positions change – then the link route(s) have to be recomputed anyway.
But when copying to a random point in a different diagram, the data is copied, including the data.points
Array. The Binding on Link.points then causes the new link to get the same points as it did in the old diagram, which is very unlikely to be correct, since the copied nodes are almost certainly in new locations.
I will assume you still want to keep that Binding on Link.points in the second Diagram. (Otherwise, again there would be no problem to begin with.)
So one solution is not to copy the data.points
Array when copying between diagrams/models. Here’s one way to do that:
myDiagram2 =
$(go.Diagram, "myDiagram2Div",
{
allowDrop: true,
nodeTemplateMap: myDiagram.nodeTemplateMap,
linkTemplateMap: myDiagram.linkTemplateMap,
"model.copyLinkData": function(linkdata) {
var copieddata = go.GraphLinksModel.prototype.copyLinkData.call(this, linkdata);
if (!(myDiagram2.currentTool instanceof go.DraggingTool)) {
copieddata.points = undefined;
}
return copieddata;
},
"animationManager.isEnabled": false,
"undoManager.isEnabled": true
}
);
Again, I’m assuming in this second Diagram that you’re sharing all of the templates from the first Diagram.
A more sophisticated solution would enable you to keep custom link routes when dragging or copy-pasting between Diagrams, but I’m sorry, that functionality doesn’t come for free and would need to be investigated and programmed.
Thank you Walter, a lot of information. But GOJS if provide drag and drop functionality link point also must be copied. Look, node rectangle position prefect copied but link position is not. it is actually real problem. node position is relative change when drop on second diagram. why link is not.
I am not saying when node is resize or move after drop to make some link reshape. after drop reshape is totally ok.
hope fix it.
OK, try the current 1.7.8 Beta library, at GoJS - Build Interactive Diagrams for the Web. You can remove the Model.copyLinkData override that I suggested above.
I think this avoids the problem that you first reported, but the new behavior is not always exactly correct if the copied nodes are differently sized compared to their original nodes.
Thank you very much. it rearly good. Thank you.