Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Diagram model from JSON file

$
0
0

@resuni wrote:

I need to load my diagram model from a JSON file. I found an example here: https://gojs.net/latest/samples/minimalJSON.html

I was able to reproduce the concepts used in this example, and everything worked except for the location of nodes, because this requires instantiation of go.Point. Because there’s no way to represent the instantiation of an object in JSON, how would I load location data from a JSON file?

For clarity, here is some sample code I would like to be able to represent in a JSON file:

diagram.model = new go.GraphLinksModel(
 [ 
  { key: "0", color: "black", loc: new go.Point(0, 100), shape: "RoundedRectangle", },
  { key: "1", color: "black", loc: new go.Point(975, 100), shape: "RoundedRectangle", },
  { key: "2", color: "black", loc: new go.Point(300, 250), shape: "RoundedRectangle", },
  { key: "3", color: "black", loc: new go.Point(625, 255), shape: "RoundedRectangle", },
  { key: "4", color: "black", loc: new go.Point(300, 560), shape: "RoundedRectangle", },
  { key: "5", color: "black", loc: new go.Point(675, 560), shape: "RoundedRectangle", },
 ],

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles