I am trying to programmatically import a process flow diagram from draw.io into GoJS, and I’ve run into a conflict between the TextBlocks and the itemArrays. Before adding the itemArray, the TextBlock renders exactly how I need it. After adding the itemArray, the TextBlock disappears. I’ve tried several different ways of ordering, formatting, nesting, and binding the two to no success. Here’s the nodeTemplate I’m using:
myDiagram.nodeTemplateMap.add("Node",
$(go.Node, "Spot",
{
locationObjectName: "SHAPE", selectionObjectName: "SHAPE", rotatable: true,
mouseEnter: doMouseEnter, click: doClick, mouseLeave: doMouseLeave
},
new go.Binding("itemArray", "itemArray"),
{
itemTemplate:
$(go.Panel, "Auto",
$(go.Shape, "Circle", { desiredSize: new go.Size(1, 1), fill: "black", fromLinkable:true, toLinkable:true }),
new go.Binding("portId", "portId"),
new go.Binding("alignment", "", function(data, node) { return new go.Spot(data.x, data.y); }),
new go.Binding("fromSpot", "", function(data, node) { return new go.Spot(data.x, data.y); }),
new go.Binding("toSpot", "", function(data, node) { return new go.Spot(data.x, data.y); })
)
},
new go.Binding("location", "pos", go.Point.parse).makeTwoWay(go.Point.stringify),
$(go.Shape, "Circle",
new go.Binding("desiredSize", "size", go.Size.parse).makeTwoWay(go.Size.stringify),
{
name: "SHAPE", strokeWidth: 2,
fill: $(go.Brush, "Linear", { 0: "gray", 0.35: "white", 0.7: "gray" })
}),
$(go.TextBlock,
{ alignment: go.Spot.Center, textAlign: "center", margin: 1 },
new go.Binding("text").makeTwoWay())
));
And here is a sample of the .json I am importing the bindings from (it is created programmatically from a draw.io .xml file).
{"key":"vX6fYtIgIG8C6GX4y9tb-8","category":"Node","pos":"281 300","text":"0","size":"20 20","itemArray":[{"portId":"N","x":"0.5","y":"0"},{"portId":"NE","x":"0.855","y":"0.145"},{"portId":"E","x":"1","y":"0.5"},{"portId":"SE","x":"0.855","y":"0.855"}, {"portId":"S","x":"0.5","y":"1"},{"portId":"SW","x":"0.145","y":"0.855"},{"portId":"W","x":"0","y":"0.5"},{"portId":"NW","x":"0.145","y":"0.145"}]},
{"key":"tQ1Rfqdzyl8Z7qJ2ouWq-12","category":"Node","pos":"1720 220","text":"1","size":"20 20","itemArray":[{"portId":"N","x":"0.5","y":"0"},{"portId":"NE","x":"0.855","y":"0.145"},{"portId":"E","x":"1","y":"0.5"},{"portId":"SE","x":"0.855","y":"0.855"}, {"portId":"S","x":"0.5","y":"1"},{"portId":"SW","x":"0.145","y":"0.855"},{"portId":"W","x":"0","y":"0.5"},{"portId":"NW","x":"0.145","y":"0.145"}]},
Thanks for any help you can provide.