@Giosk wrote:
I have a diagram with entity and links and following this example I’m trying to save the entities and links position and following restore them.
The diagram is very simple, and is initialized like that:
myDiagram = $(go.Diagram, "myDiagramDiv", { initialContentAlignment: go.Spot.Center, initialAutoScale: go.Diagram.Uniform, layout: $(go.TreeLayout, { angle: 90, nodeSpacing: 100, layerSpacing: 100, setsPortSpot: IS_TREE_LINK, setsChildPortSpot: IS_TREE_LINK, }), ... }
In my entity template I have bind the coordinates to location:
new go.Binding("location", "Coordinates", Coordinates => { return go.Point.parse(Coordinates) }).makeTwoWay(go.Point.stringify),
and in my link template I have bind the points:
new go.Binding("points").makeTwoWay(),
I have the following problems:
when I receive data with coordinates and points empty or null, the links in the diagram follow a very strange and chaotic path.
I created the following function for saving links points:
const points = myDiagram.model.linkDataArray.map(lda => { let flattenPoints = [] lda.points.n && lda.points.n.forEach(elem => { flattenPoints.push(elem.x) flattenPoints.push(elem.y) }) return { points JSON.stringify(flattenPoints), } })
but sometimes the
lda.points.n
is null and I can’t explain why.
Do you have any advices?Thanks
Posts: 2
Participants: 2