Hi Walter,
Thanks for quick response . This is the code i have written. Say i have 100 nodes, only 10 nodes are key (like parent nodes) and others are like children nodes.
Ex: nwoods have 100 employees and nwoods work with 3 client companies. nwoods employee can work with more than one client company. These 3 client companies might have employees of their own (not nwoods employee). I came up with this code to full fill my requirements. My goal is to sort nwoods, client1, client2 and client3 nodes in this order and all other nodes I don’t mind the sort because they are children.
myDiagram =
$(go.Diagram, “myDiagram”,
{“animationManager.isEnabled”: false,
contentAlignment: go.Spot.TopLeft,
autoScale: go.Diagram.Uniform,
isReadOnly: false,
“toolManager.mouseWheelBehavior”: go.ToolManager.WheelZoom,
“linkingTool.direction”: go.LinkingTool.ForwardsOnly,
layout: $(go.LayeredDigraphLayout, { direction: 90, layerSpacing: 10, setsPortSpots: false })
});
myDiagram.startTransaction("shift left");
myDiagram.nodeTemplate =
$(go.Node, "Auto",
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
$(go.Panel, "Table",
{ name: "SHAPE", margin: 4,
opacity: 1},
$(go.RowColumnDefinition,
{
column: 0,
stretch: go.GraphObject.Horizontal,
alignment: go.Spot.Left
}),
$(go.Picture,
{
row: 0, column: 0,
desiredSize: new go.Size(150, 26),
margin: 0,
imageStretch: go.GraphObject.Uniform,
alignment: go.Spot.BottomLeft
},
new go.Binding("source", "pyramid", pyramidLevel).makeTwoWay()),
$(go.Picture,
{
row: 0, column: 1,
desiredSize: new go.Size(34, 26), margin: 0,
imageStretch: go.GraphObject.Uniform,
alignment: go.Spot.BottomRight
},
new go.Binding("source", "img", LocationImage).makeTwoWay()),
$(go.TextBlock,
{
row: 1, column: 0,
maxSize: new go.Size(150, NaN), margin: 2,
font: "bold 8pt sans-serif",
alignment: go.Spot.Top, background: "white"
},
new go.Binding("text", "name").makeTwoWay())
)
);
myDiagram.linkTemplate =
$(go.Link,
new go.Binding("points").makeTwoWay(),
{ curve: go.Link.Bezier, toShortLength: 5 },
new go.Binding("curviness", "curviness"),
$(go.Shape, // the link shape
new go.Binding("stroke", "color"),
{ strokeWidth: 2.5 }),
$(go.Shape, // the arrowhead
new go.Binding("fill", "color"),
{ toArrow: "kite", stroke: null, scale: 1.5 })
);
var nodeDataArray = [
{ "name": "Dashboard", "img": "", "pyramid": "" },
{ "name": "Sheets", "img": "", "pyramid": "" },
{ "name": "Objects", "img": "", "pyramid": "" },
{ "name": "Dimensions", "img": "", "pyramid": "" },
{ "name": "Facts", "img": "", "pyramid": "" },
{ "name": "Notes", "img": "", "pyramid": "" }
];
var linkDataArray = [
{ "from": "Dashboard", "to": "Sheets" },
{ "from": "Dashboard", "to": "Notes" },
{ "from": "Sheets", "to": "Objects" },
{ "from": "Sheets", "to": "Notes" },
{ "from": "Objects", "to": "Dimensions" },
{ "from": "Objects", "to": "Facts" },
{ "from": "Objects", "to": "Notes" }
];
myDiagram.clear();
myDiagram.model = new go.GraphLinksModel(nodeDataArray, linkDataArray);
myDiagram.layoutDiagram(true);
function LocationImage(vimg) {
if (vimg === "oracle") return "oracle.jpg";
if (vimg === "teradata") return "teradata.jpg";
if (vimg === "file server") return "file server.jpg";
if (vimg === "qlikview server") return "qlikview server.jpg";
}
function pyramidLevel(levelColor) {
if (levelColor === "1") return "ST.png";
if (levelColor === "2") return "DT.png";
if (levelColor === "3") return "AI.png";
if (levelColor === "4") return "ET.png";
if (levelColor === "5") return "TS.png";
if (levelColor === "6") return "AG.png";
if (levelColor === "7") return "FS.png";