dear All!
I want make link have difference curve and routing in the same diagram.
so I use template like below:
go.link new binding("curve", "curve").makeToWay()
go.link new binding("routing ", "routing ").makeToWay()
when i change the link curve as Bezier , I use Load methoed, the result is
"curve" : {"Ub":"Bezier", "FF":9}, "routing": {"Ub":"Orthogonal", "FF":9}
but when I fromJson show .
the link lost the property.
so i want to know how to save link’s curve or routing ?
thank you!!
simon
2
Can you give us your complete link template?
myDiagram.linkTemplate =
$(go.Link,
new go.Binding("curve", "curve").makeTwoWay(),
new go.Binding("routing", "routing").makeTwoWay(),
{ relinkableFrom: true, relinkableTo: true }, // allow the user to relink existing links
$(go.Shape,
{ strokeWidth: 2 },
new go.Binding("stroke", "color")),
$(go.Shape,
{ toArrow: "Standard", stroke: null },
new go.Binding("fill", "color"))
);
diagram toJson result is
{ "class": "go.GraphLinksModel",
"nodeDataArray": [
{"key":1, "loc":"175 100"},
{"key":2, "loc":"175 190"}
],
"linkDataArray": [ {"from":1, "to":2, "fromPort":"B", "toPort":"T", "curve":{"Ub":"Bezier", "FF":9}} ]}
thank you very much!
simon
4
I see sorry, we don’t make it very clear, but because those properties are enums you must use Binding.parseEnum:
myDiagram.linkTemplate =
$(go.Link,
new go.Binding('curve', 'curve', go.Binding.parseEnum(go.Link, go.Link.Normal)).makeTwoWay(Binding.toString),
new go.Binding('routing', 'routing', go.Binding.parseEnum(go.Link, go.Link.Normal)).makeTwoWay(Binding.toString),
{ relinkableFrom: true, relinkableTo: true }, // allow the user to relink existing links
$(go.Shape,
{ strokeWidth: 2 },
new go.Binding("stroke", "color")),
$(go.Shape,
{ toArrow: "Standard", stroke: null },
new go.Binding("fill", "color"))
);
The JSON output would be the name of the enum, like:
"linkDataArray": [
{"from":"Alpha", "to":"Beta", "routing":"Orthogonal"}, ...
I tested this in a small example and it works. Let me know if you run into any issues.
it works thank you again, you are the best!!