How to additional JSON data to the node?


#1

Hi Walter,

I am using GoJS in my project. I want add additional data to the node which is in JSON format and i have different data for each node.

I am using angular 5;

 nodedataArray = [{
key: 3,
text: 'Expression Evaluator',
figure: 'RoundedRectangle',
fill: 'lightskyblue',
source: 'assets/ExpressionEvaluator.png',
leftArray: [{ 'portId': 'portleft' }],
rightArray: [{ 'portId': 'portright' }],
'loc': '-120.33334350585938 10.66666665673256'},{
key: 4, text: 'DeviceType', figure: 'RoundedRectangle', fill: '#ff8080',
source: 'assets/DeviceTypeSelector.png', leftArray: [],
rightArray: [{ 'portId': 'right0' }, { 'portId': 'right1' }], 'loc': '-351.3333435058594 9.66666665673256'

}];

i want to add my json as

data

inside node which will come from server.

nodedataArray = [{
key: 3,
text: 'Expression Evaluator',
figure: 'RoundedRectangle',
fill: 'lightskyblue',
data: [
  {
    "allowApplicationActivation": false,
    "class": "gateway",
    "model": "ModelQA",
    "name": "uppercase",
    "typeId": {
      "category": "01",
      "manufacturer": "ADD1"
    }
  },
  {
    "allowApplicationActivation": false,
    "class": "gateway",
    "model": "mtcdt-lcdt",
    "name": "lightweight",
    "typeId": {
      "category": "01",
      "manufacturer": "ADSG"
    }
  },
  {
    "allowApplicationActivation": false,
    "class": "sensor",
    "model": "m2018",
    "name": "amnimotseries",
    "typeId": {
      "category": "00",
      "manufacturer": "AMNM"
    }
  }],
source: 'assets/ExpressionEvaluator.png',
leftArray: [{ 'portId': 'portleft' }],
rightArray: [{ 'portId': 'portright' }],
'loc': '-120.33334350585938 10.66666665673256' }];

so that i can access the data in typescript when i want to show the properties of specific node, please help me.

Thanks in advance!


#2

someNode.data gives you a reference to the node data object.

In your example, someNode.data.text would be “Expression Evaluator”.

And someNode.data.data would be the additional information that you read from JSON-formatted text, an Array.


#3

Thank you Walter.
It’s working i can access the data for different nodes and i can convert to
Model.toJson()
without any trouble.

I have another question

I have gone through ToolTips

But i am thinking how can i get addition properties like a slide-down below the node instead of tool-tip.

In my project when i drag and drop a node into to the diagram, the additional properties should automatically slide-down below the node.

Any help on this will be great!