How to use goJs TreeModel in angular 7

655 Views Asked by At

I am trying to create a tree model with a set of links and nodes. I have it in my jsfiddle using javascript it works fine. I am trying to replicate the same in angular. I could not find any helpfull info. I am getting the below error when i try to pass the same as i did in javascript.

  this.myDiagram.model = new go.TreeModel({
            nodeParentKeyProperty : "Boss",
            nodeDataArrayProperty
        });

Here's the working javascript version of the code : https://jsfiddle.net/pandiyancool/58os19nt/6/

Error message shown in vscode

2

There are 2 best solutions below

0
On BEST ANSWER

Use the TreeModel of gojs like below

const $ = go.GraphObject.make;
....
this.myDiagram.model = $(go.TreeModel, {
    nodeParentKeyProperty: "boss",
    nodeDataArray: nodeDataArrayProperty
});
0
On

The TreeModel constructor does not take an Object specifying options. It only takes an optional Array of data. https://gojs.net/latest/api/symbols/TreeModel.html

If you do want to set various properties on a new instance of TreeModel, use the static GraphObject.make function: https://gojs.net/latest/api/symbols/GraphObject.html#.make