Hi,
Am able to see the one set of nodes in both View and log and the other set for bottom half is not viewable and only in log as a combined array of objects.
In console.log(state.diagramNodeData) am able to see All the data fetched from Devices and Users with category property… but my intiFunction in similar sample with static data is working fine, but in the project it is giving me No Node template found for category “” and Using default node template.
Could you please help me where am I going wrong
public initDiagram(): go.Diagram {
const $ = go.GraphObject.make;
const dia = $(go.Diagram, {
'undoManager.isEnabled': true,
// layout: $(go.GridLayout, {
// wrappingColumn: -1,
// // alignment: go.GridLayout.Forward,
// // sorting: go.GridLayout.Ascending,
// spacing: new go.Size(20, 10),
// // background: "lightyellow"
// }),
model: $(go.GraphLinksModel, {
linkKeyProperty: 'key', // IMPORTANT! must be defined for merges and data
// positive keys for nodes
makeUniqueKeyFunction: (m: go.Model, data: any) => {
let k = data.key || 1;
while (m.findNodeDataForKey(k)) k++;
data.key = k;
return k;
},
nodeKeyProperty: "key"
}),
});
const deviceTemplate = $(go.Node, "Auto", {
locationSpot: go.Spot.TopCenter,
// isShadowed: true,
shadowOffset: new go.Point(1, 1),
// shadowColor: "#cccccc",
},
// {
// click: (e, node) => {
// node.diagram.clearHighlighteds();
// const n = node.part.data;
// this.selectedDeviceId = n.id;
// console.log("selected Device ID is " + n.id);
// GridviewComponent.isSelIdPresent = GridviewComponent.staticSelDvUs1.filter(user => user.deviceId === n.id);
// console.log(GridviewComponent.isSelIdPresent);
// for (const user of GridviewComponent.staticSelDvUs1) {
// if (user.deviceId === n.id) {
// const name = user.name;
// console.log("selected Device is " + n.name)
// console.log(name + " To be Higlighted NAME")
// node.diagram.findNodesByExample({ name }).each(element => {
// element.isHighlighted = true;
// console.log(element.data.name + " is Matched")
// console.log(" HIGHLIGHT is set to true")
// // element.updateTargetBindings();
// });
// } else {
// n.isHighlighted = false;
// console.log(n.name)
// console.log(user.name)
// console.log(" HIGHLIGHT is set to false")
// }
// }
// }
// },
// ----------------------Binding for category based on ID Property
// new go.Binding("category", "id", (id) => {
// if (id) {
// return "device"; // set category to "device" if id exists
// } else {
// return "user"; // set category to "user" if id doesn't exist
// }
// }),
// // ----------------------Binding for category based on ID Property
$(go.Shape, "RoundedRectangle",
{
width: 100,
height: 50,
fill: "lightblue",
stroke: "#6c767e",
strokeWidth: 1,
}
),
$(go.TextBlock,
{
alignment: go.Spot.Center,
margin: 5,
stroke: "black",
textAlign: "center",
font: "14pt Sego UI,sans-serif",
maxSize: new go.Size(150, NaN),
},
new go.Binding("text", "name").makeTwoWay()
),
);
const userTemplate = $(go.Node, "Auto", {
locationSpot: go.Spot.BottomCenter,
// isShadowed: true,
shadowOffset: new go.Point(1, 1),
// shadowColor: "#cccccc",
},
$(go.Shape, "RoundedRectangle",
{
width: 100,
height: 50,
fill: "#adbce6",
stroke: "#6c767e",
strokeWidth: 1
},
// the Shape.stroke color depends on whether Node.isHighlighted is true
new go.Binding("stroke", "isHighlighted", h => h ? "red" : "black").ofObject(),
new go.Binding("strokeWidth", "isHighlighted", h => h ? 3 : 1).ofObject(),
),
$(go.TextBlock,
{
alignment: go.Spot.Center,
margin: 5,
stroke: "black",
textAlign: "center",
font: "14pt Sego UI,sans-serif",
maxSize: new go.Size(150, NaN),
},
new go.Binding("text", "name").makeTwoWay()
),
);
const templmap = new go.Map<string, go.Node>();
templmap.add("Device", deviceTemplate);
templmap.add("User", userTemplate);
dia.nodeTemplateMap = templmap;
return dia;
};
Thanks,
Ganesh