Forgive me - I’m still a newbie.
My templates are that which is given in the ContinuousForceDirectedLayout example so I can’t see any node binding to position or location.
- Should I add these?
- Should they look like :-
new go.Binding(“location”, “loc”), // get the Node.location from the data.loc value
new go.Binding(“position”, “pos”), // get the Node.position from the data.pos value
- Does that mean I need to provide that data in the JSON?
- If so, does the data need to be explicit e.g. real coordinates?
Yes, I pass the exact string the second time as the first.
I’ve add the “layout” to console dump :-
---- After Diagram init and model.fromJson ----
careerDiagram = initGOjsDiagram();
diagramData = retrieveDiagramData();
careerDiagram.model = go.Model.fromJson(diagramData);
careerDiagram.nodes.count = 3
careerDiagram.links.count = 3
careerDiagram.model.nodeDataArray.length = 3
careerDiagram.documentBounds = Rect(NaN,NaN,NaN,NaN)
careerDiagram.viewportBounds = Rect(NaN,NaN,1312,798)
careerDiagram.layout = ContinuousForceDirectedLayout( for Diagram “myDiagramDiv”)
"careerDiagram.layout = "
{
[functions]: ,
$h: true,
__gohashid: 194,
proto: { },
_isObserving: false,
aq: true,
arrangementOrigin: { },
arrangementSpacing: { },
arrangesToOrigin: false,
Bo: 100,
CK: 1000,
comments: false,
currentIteration: 0,
defaultCommentElectricalCharge: 5,
defaultCommentSpringLength: 10,
defaultElectricalCharge: 100,
defaultGravitationalMass: 0,
defaultSpringLength: 30,
defaultSpringStiffness: 0.05,
diagram: { },
Dx: { },
Eg: null,
epsilonDistance: 1,
Gf: false,
gK: 0,
group: null,
gz: null,
h: { },
hI: true,
infinityDistance: 1000,
isInitial: true,
isOngoing: true,
isRealtime: true,
isRouting: true,
isValidLayout: false,
isViewportSized: false,
je: { },
KD: { },
Kh: false,
ks: { },
Lj: true,
lK: 100,
lr: true,
maxIterations: 100,
mg: { },
mH: 5,
mK: 0,
Mq: 5,
nE: 1,
network: null,
nH: 10,
Nq: 10,
nr: true,
or: true,
ox: false,
pA: 100,
pq: { },
QE: true,
qq: false,
randomNumberGenerator: { },
RE: true,
rK: 30,
Rt: true,
Ry: null,
setsPortSpots: true,
Sh: 1000,
sK: 0.05,
TG: false,
Tn: 100,
to: false,
ur: false,
VB: “”,
Vn: 0,
Wn: 30,
wr: 0,
Xn: 0.05,
Xq: 1,
Z: { }
}
Layer “Grid”
Layer “Background”
Layer “”
Node#1146(Web Developer) cdgmstABL vp Rect(NaN,NaN,25.3,25.3) n:Rect(0,0,25.3,25.3) elts:2 data:[object Object]
Shape(Circle)#1149 vp Rect(0,0,25.3,25.3) n:Rect(0,0,24.3,24.3)
TextBlock(“Web Developer”) vp Rect(8.65,5.5,8,14.3) n:Rect(0,0,8,14.3)
Node#1151(Other Developer) cdgmstABL vp Rect(NaN,NaN,25.3,25.3) n:Rect(0,0,25.3,25.3) elts:2 data:[object Object]
Shape(Circle)#1154 vp Rect(0,0,25.3,25.3) n:Rect(0,0,24.3,24.3)
TextBlock(“Other Developer”) vp Rect(8.65,5.5,8,14.3) n:Rect(0,0,8,14.3)
Node#1156(Media Developer) cdgmstABL vp Rect(NaN,NaN,25.3,25.3) n:Rect(0,0,25.3,25.3) elts:2 data:[object Object]
Shape(Circle)#1159 vp Rect(0,0,25.3,25.3) n:Rect(0,0,24.3,24.3)
TextBlock(“Media Developer”) vp Rect(8.65,5.5,8,14.3) n:Rect(0,0,8,14.3)
Link#1163(Web to Media) cdgmhstABL vp Rect(NaN,NaN,NaN,NaN) elts:3 data:[object Object]
Shape(None)#1166 vp Rect(NaN,NaN,NaN,NaN)
Shape(Standard)#1167 vp Rect(NaN,NaN,NaN,NaN)
Panel(Panel.Auto)#1168 vp Rect(NaN,NaN,NaN,NaN) elts:2
Shape(None)#1170 vp Rect(NaN,NaN,NaN,NaN)
TextBlock(“Web to Media”) vp Rect(NaN,NaN,NaN,NaN) n:Rect(0,0,82,14.3)
Link#1172(Other to Web) cdgmhstABL vp Rect(NaN,NaN,NaN,NaN) elts:3 data:[object Object]
Shape(None)#1175 vp Rect(NaN,NaN,NaN,NaN)
Shape(Standard)#1176 vp Rect(NaN,NaN,NaN,NaN)
Panel(Panel.Auto)#1177 vp Rect(NaN,NaN,NaN,NaN) elts:2
Shape(None)#1179 vp Rect(NaN,NaN,NaN,NaN)
TextBlock(“Other to Web”) vp Rect(NaN,NaN,NaN,NaN) n:Rect(0,0,79,14.3)
Link#1181(Media to Other) cdgmhstABL vp Rect(NaN,NaN,NaN,NaN) elts:3 data:[object Object]
Shape(None)#1184 vp Rect(NaN,NaN,NaN,NaN)
Shape(Standard)#1185 vp Rect(NaN,NaN,NaN,NaN)
Panel(Panel.Auto)#1186 vp Rect(NaN,NaN,NaN,NaN) elts:2
Shape(None)#1188 vp Rect(NaN,NaN,NaN,NaN)
TextBlock(“Media to Other”) vp Rect(NaN,NaN,NaN,NaN) n:Rect(0,0,88,14.3)
Layer “Foreground”
Layer “Adornment”
Layer “Tool”
undefined
function onUpdateModelClick()
{
console.log("---- Before model.toJson ----");
console.log("careerDiagram.nodes.count = ", careerDiagram.nodes.count);
console.log("careerDiagram.links.count = ", careerDiagram.links.count);
console.log("careerDiagram.model.nodeDataArray.length = ", careerDiagram.model.nodeDataArray.length);
console.log("careerDiagram.documentBounds = ", careerDiagram.documentBounds.toString());
console.log("careerDiagram.viewportBounds = ", careerDiagram.viewportBounds.toString());
console.log("careerDiagram.layout = ", careerDiagram.layout);
console.log(go.Debug.dumpVisualTree(careerDiagram));
careerDiagram.model = go.Model.fromJSON(careerDiagram.model.toJSON());
console.log("---- After model.toJson ----");
console.log("careerDiagram.nodes.count = ", careerDiagram.nodes.count);
console.log("careerDiagram.links.count = ", careerDiagram.links.count);
console.log("careerDiagram.model.nodeDataArray.length = ", careerDiagram.model.nodeDataArray.length);
console.log("careerDiagram.documentBounds = ", careerDiagram.documentBounds.toString());
console.log("careerDiagram.viewportBounds = ", careerDiagram.viewportBounds.toString());
console.log("careerDiagram.layout = ", careerDiagram.layout);
console.log(go.Debug.dumpVisualTree(careerDiagram));
};
---- Before model.toJson ----
careerDiagram.nodes.count = 3
careerDiagram.links.count = 3
careerDiagram.model.nodeDataArray.length = 3
careerDiagram.documentBounds = Rect(-119.33483917433506,-113.07893157753484,262.9432780753119,264.2642083625452)
careerDiagram.viewportBounds = Rect(-643.8632001366791,-379.9468273962622,1312,798)
careerDiagram.layout = ContinuousForceDirectedLayout( for Diagram “myDiagramDiv”)
"careerDiagram.layout = "
{
[functions]: ,
$h: true,
__gohashid: 194,
proto: { },
_isObserving: true,
aq: true,
arrangementOrigin: { },
arrangementSpacing: { },
arrangesToOrigin: false,
Bo: 100,
CK: 1000,
comments: false,
currentIteration: 13,
defaultCommentElectricalCharge: 5,
defaultCommentSpringLength: 10,
defaultElectricalCharge: 100,
defaultGravitationalMass: 0,
defaultSpringLength: 30,
defaultSpringStiffness: 0.05,
diagram: { },
Dx: { },
Eg: null,
epsilonDistance: 1,
Gf: true,
gK: 13,
group: null,
gz: { },
h: { },
hI: true,
infinityDistance: 1000,
isInitial: true,
isOngoing: true,
isRealtime: true,
isRouting: true,
isValidLayout: true,
isViewportSized: false,
je: { },
KD: { },
Kh: false,
ks: { },
Lj: true,
lK: 100,
lr: true,
maxIterations: 100,
mg: { },
mH: 5,
mK: 0,
Mq: 5,
nE: 1,
network: { },
nH: 10,
Nq: 10,
nr: true,
or: true,
ox: false,
pA: 100,
pq: { },
QE: true,
qq: false,
randomNumberGenerator: { },
RE: true,
rK: 30,
Rt: true,
Ry: null,
setsPortSpots: true,
Sh: 1000,
sK: 0.05,
TG: false,
Tn: 100,
to: true,
ur: false,
VB: “”,
Vn: 0,
Wn: 30,
wr: 13,
Xn: 0.05,
Xq: 1,
Z: { }
}
Layer “Grid”
Layer “Background”
Layer “”
Node#1146(Web Developer) cdgmstABL vp Rect(31.608438900976892,39.18527678501037,107,107) n:Rect(0,0,107,107) elts:2 data:[object Object]
Shape(Circle)#1149 vp Rect(0,0,107,107) n:Rect(0,0,106,106)
TextBlock(“Web Developer”) vp Rect(5.5,46.35,96,14.3) n:Rect(0,0,96,14.3)
Node#1151(Other Developer) cdgmstABL vp Rect(-114.33483917433506,31.65073131072188,75,75) n:Rect(0,0,75,75) elts:2 data:[object Object]
Shape(Circle)#1154 vp Rect(0,0,75,75) n:Rect(0,0,74,74)
TextBlock(“Other Developer”) vp Rect(5.5,23.2,64,28.6) n:Rect(0,0,64,28.6)
Node#1156(Media Developer) cdgmstABL vp Rect(-15.94658690622705,-108.07893157753484,75,75) n:Rect(0,0,75,75) elts:2 data:[object Object]
Shape(Circle)#1159 vp Rect(0,0,75,75) n:Rect(0,0,74,74)
TextBlock(“Media Developer”) vp Rect(5.5,23.2,64,28.6) n:Rect(0,0,64,28.6)
Link#1163(Web to Media) cdgmhstABL vp Rect(-8.492030763034261,-33.90455499660645,91,81.90230718084021) n:Rect(0,0,91,81.90230718084021) elts:3 data:[object Object]
Shape(None)#1166 vp Rect(34.476541687851,0,30.9823913474419,81.90230718084021) n:Rect(0,0,29.9823913474419,80.90230718084021)
Shape(Standard)#1167 vp Rect(31.06827342757625,0.4609251897114035,9,9) n:Rect(0,0,8,8) a:262.443954356173
Panel(Panel.Auto)#1168 vp Rect(0,31.06791600473364,91,23.3) n:Rect(0,0,91,23.3) elts:2
Shape(None)#1170 vp Rect(0,0,91,23.3) n:Rect(0,0,90,22.3)
TextBlock(“Web to Media”) vp Rect(4.5,4.5,82,14.3) n:Rect(0,0,82,14.3)
Link#1172(Other to Web) cdgmhstABL vp Rect(-45.70363486264702,53.74173806354768,88,23.69940255125126) n:Rect(0,0,88,23.69940255125126) elts:3 data:[object Object]
Shape(None)#1175 vp Rect(5.6447908259802375,9.825350713722466,72.54175218522337,10.384676048827373) n:Rect(0,-0.015957006603073864,71.54175218522337,9.384676048827373)
Shape(Standard)#1176 vp Rect(71.7761306903429,14.699402551251264,9,9) n:Rect(0,0,8,8) a:19.902229640760335
Panel(Panel.Auto)#1177 vp Rect(0,0,88,23.3) n:Rect(0,0,88,23.3) elts:2
Shape(None)#1179 vp Rect(0,0,88,23.3) n:Rect(0,0,87,22.3)
TextBlock(“Other to Web”) vp Rect(4.5,4.5,79,14.3) n:Rect(0,0,79,14.3)
Link#1181(Media to Other) cdgmhstABL vp Rect(-64.60847474141187,-36.3537748479615,97,81.96729308915053) n:Rect(0,0,97,81.96729308915053) elts:3 data:[object Object]
Shape(None)#1184 vp Rect(15.194731503463614,0,57.31040917333179,78.96862212734812) n:Rect(0,0,56.31040917333179,77.96862212734812)
Shape(Standard)#1185 vp Rect(14.545263015830034,72.96729308915053,9,9) n:Rect(0,0,8,8) a:138.12153974999677
Panel(Panel.Auto)#1186 vp Rect(0,32.109903072025965,97,23.3) n:Rect(0,0,97,23.3) elts:2
Shape(None)#1188 vp Rect(0,0,97,23.3) n:Rect(0,0,96,22.3)
TextBlock(“Media to Other”) vp Rect(4.5,4.5,88,14.3) n:Rect(0,0,88,14.3)
Layer “Foreground”
Layer “Adornment”
Layer “Tool”
undefined
---- After model.toJson ----
careerDiagram.nodes.count = 3
careerDiagram.links.count = 3
careerDiagram.model.nodeDataArray.length = 3
careerDiagram.documentBounds = Rect(-119.33483917433506,-113.07893157753484,262.9432780753119,264.2642083625452)
careerDiagram.viewportBounds = Rect(-643.8632001366791,-379.9468273962622,1312,798)
careerDiagram.layout = ContinuousForceDirectedLayout( for Diagram “myDiagramDiv”)
"careerDiagram.layout = "
{
[functions]: ,
$h: true,
__gohashid: 194,
proto: { },
_isObserving: true,
aq: true,
arrangementOrigin: { },
arrangementSpacing: { },
arrangesToOrigin: false,
Bo: 100,
CK: 1000,
comments: false,
currentIteration: 13,
defaultCommentElectricalCharge: 5,
defaultCommentSpringLength: 10,
defaultElectricalCharge: 100,
defaultGravitationalMass: 0,
defaultSpringLength: 30,
defaultSpringStiffness: 0.05,
diagram: { },
Dx: { },
Eg: null,
epsilonDistance: 1,
Gf: false,
gK: 13,
group: null,
gz: { },
h: { },
hI: true,
infinityDistance: 1000,
isInitial: true,
isOngoing: true,
isRealtime: true,
isRouting: true,
isValidLayout: false,
isViewportSized: false,
je: { },
KD: { },
Kh: false,
ks: { },
Lj: true,
lK: 100,
lr: true,
maxIterations: 100,
mg: { },
mH: 5,
mK: 0,
Mq: 5,
nE: 1,
network: { },
nH: 10,
Nq: 10,
nr: true,
or: true,
ox: false,
pA: 100,
pq: { },
QE: true,
qq: false,
randomNumberGenerator: { },
RE: true,
rK: 30,
Rt: true,
Ry: null,
setsPortSpots: true,
Sh: 1000,
sK: 0.05,
TG: false,
Tn: 100,
to: false,
ur: false,
VB: “”,
Vn: 0,
Wn: 30,
wr: 13,
Xn: 0.05,
Xq: 1,
Z: { }
}
Layer “Grid”
Layer “Background”
Layer “”
Node#2332(Web Developer) cdgmstABL vp Rect(NaN,NaN,25.3,25.3) n:Rect(0,0,25.3,25.3) elts:2 data:[object Object]
Shape(Circle)#2335 vp Rect(0,0,25.3,25.3) n:Rect(0,0,24.3,24.3)
TextBlock(“Web Developer”) vp Rect(8.65,5.5,8,14.3) n:Rect(0,0,8,14.3)
Node#2337(Other Developer) cdgmstABL vp Rect(NaN,NaN,25.3,25.3) n:Rect(0,0,25.3,25.3) elts:2 data:[object Object]
Shape(Circle)#2340 vp Rect(0,0,25.3,25.3) n:Rect(0,0,24.3,24.3)
TextBlock(“Other Developer”) vp Rect(8.65,5.5,8,14.3) n:Rect(0,0,8,14.3)
Node#2342(Media Developer) cdgmstABL vp Rect(NaN,NaN,25.3,25.3) n:Rect(0,0,25.3,25.3) elts:2 data:[object Object]
Shape(Circle)#2345 vp Rect(0,0,25.3,25.3) n:Rect(0,0,24.3,24.3)
TextBlock(“Media Developer”) vp Rect(8.65,5.5,8,14.3) n:Rect(0,0,8,14.3)
Link#2347(Web to Media) cdgmhstABL vp Rect(NaN,NaN,NaN,NaN) elts:3 data:[object Object]
Shape(None)#2350 vp Rect(NaN,NaN,NaN,NaN)
Shape(Standard)#2351 vp Rect(NaN,NaN,NaN,NaN)
Panel(Panel.Auto)#2352 vp Rect(NaN,NaN,NaN,NaN) elts:2
Shape(None)#2354 vp Rect(NaN,NaN,NaN,NaN)
TextBlock(“Web to Media”) vp Rect(NaN,NaN,NaN,NaN) n:Rect(0,0,82,14.3)
Link#2356(Other to Web) cdgmhstABL vp Rect(NaN,NaN,NaN,NaN) elts:3 data:[object Object]
Shape(None)#2359 vp Rect(NaN,NaN,NaN,NaN)
Shape(Standard)#2360 vp Rect(NaN,NaN,NaN,NaN)
Panel(Panel.Auto)#2361 vp Rect(NaN,NaN,NaN,NaN) elts:2
Shape(None)#2363 vp Rect(NaN,NaN,NaN,NaN)
TextBlock(“Other to Web”) vp Rect(NaN,NaN,NaN,NaN) n:Rect(0,0,79,14.3)
Link#2365(Media to Other) cdgmhstABL vp Rect(NaN,NaN,NaN,NaN) elts:3 data:[object Object]
Shape(None)#2368 vp Rect(NaN,NaN,NaN,NaN)
Shape(Standard)#2369 vp Rect(NaN,NaN,NaN,NaN)
Panel(Panel.Auto)#2370 vp Rect(NaN,NaN,NaN,NaN) elts:2
Shape(None)#2372 vp Rect(NaN,NaN,NaN,NaN)
TextBlock(“Media to Other”) vp Rect(NaN,NaN,NaN,NaN) n:Rect(0,0,88,14.3)
Layer “Foreground”
Layer “Adornment”
Layer “Tool”
undefined