Hi Walter,
Thanks a lot for your inputs.
We tried that way customizing the TreeLayout . We are very near to our requirement but facing some alignment issues in two things.
- Alignment of that “arrow” shape object based on the group object
- Alignment of the nodes in the tree( indentation)
I believe what I am trying to do is right codewise, but I feel like "alignment" property is not working in my code.
Can you help me, if I am missing something or any other property is overriding that one in the above mentioned two places.
Note: Even if I am giving alignment as go.Spot.Right by default for both the group objects instead of binding it based on the group, the arrow object is taking left position only.
Attaching the screenshots of the current scenario:
Here is the nodeTemplate and TreeLayout custom function we are using:
var nodeTemplate =
$(go.Node, {
fromLinkable : false,
toLinkable : false
},
$(go.Shape, "RoundedRectangle", {
width: 260,
// stretch: go.GraphObject.Horizontal,
height: 25
}),
$(go.Panel, "Horizontal",
{
name: "indentPanel",
// alignment: go.Spot.Left, // This spot gets modified by the layout to be more indented
// alignmentFocus: go.Spot.Left,
margin: new go.Margin(0,0,0,15)
},
$("TreeExpanderButton", {
width: 14,
height: 14
}),
$(go.Panel, "Horizontal",
$(go.TextBlock, {
stroke: "#333333",
margin: 2,
},
new go.Binding("text", "name")))
),
// The arrow that acts as a port on either the left or ride side
$(go.Shape,
{
figure: "TriangleRight",
margin: new go.Margin(8,0,0,0),
width: 8.5, height: 8.5,
fill: "white",
stroke: "lightgray",
strokeWidth: 1
},
new go.Binding("portId", "portId").ofObject(),
new go.Binding("alignment", "containingGroup", function (group) {
if (group !== null && group.data.key.includes("group2")) return go.Spot.Left;
return go.Spot.Right;
}).ofObject(),
new go.Binding("alignmentFocus", "containingGroup", function (group) {
if (group !== null && group.data.key.includes("group2")) return go.Spot.Left;
return go.Spot.Right;
}).ofObject(),
new go.Binding("fromLinkable", "containingGroup", function (group) {
return !(group !== null && group.data.key.includes("group2"));
}).ofObject(),
new go.Binding("toLinkable", "containingGroup", function (group) {
return (group !== null && group.data.key.includes("group2"));
}).ofObject()
)
);
function TreeLayout() {
go.TreeLayout.call(this);
}
go.Diagram.inherit(TreeLayout, go.TreeLayout);
TreeLayout.prototype.commitNodes = function () {
go.TreeLayout.prototype.commitNodes.call(this);
var vit = this.network.vertexes.iterator;
while (vit.next()) {
var v = vit.value;
var indentPanel = v.node.findObject("indentPanel");
var indent = (v.level * 26) + 20;
if (indentPanel !== null) indentPanel.alignment = new go.Spot(0, 0.8, indent, 0);
}
};