New ids after fromJSON #1841
-
Hi, I've got the following JSON to load the graph: {
"cells":[
{
"type":"mindock.Node",
"position":{
"x":0,
"y":0
},
"size":{
"width":287.1171875,
"height":77.5
},
"angle":0,
"hidden":false,
"collapsed":false,
"depth":0,
"markup":[
{
"tagName":"g",
"selector":"buttonGroup",
"children":[
{
"tagName":"rect",
"selector":"button",
"attributes":{
"pointer-events":"visiblePainted"
}
},
{
"tagName":"path",
"selector":"buttonSign",
"attributes":{
"fill":"none",
"pointer-events":"none"
}
}
]
},
{
"tagName":"rect",
"selector":"body"
},
{
"tagName":"text",
"selector":"label"
}
],
"id":"d732ec65-ce1b-4562-a2fc-3faf191ae585",
"z":1,
"lastChildDirection":"L",
"attrs":{
"body":{
"paddingX":32,
"paddingY":24,
"stroke":"#2596FF",
"fill":"#2596FF"
},
"label":{
"fill":"#FFFFFF",
"fontSize":24,
"fontWeight":600,
"text":"Центральная тема"
},
"buttonSign":{
"strokeWidth":1.8,
"d":"M 2 5 8 5"
}
}
},
{
"type":"mindock.Node",
"position":{
"x":407.1171875,
"y":-46.75
},
"size":{
"width":180.1328125,
"height":60.5
},
"angle":0,
"hidden":false,
"collapsed":false,
"depth":1,
"markup":[
{
"tagName":"g",
"selector":"buttonGroup",
"children":[
{
"tagName":"rect",
"selector":"button",
"attributes":{
"pointer-events":"visiblePainted"
}
},
{
"tagName":"path",
"selector":"buttonSign",
"attributes":{
"fill":"none",
"pointer-events":"none"
}
}
]
},
{
"tagName":"rect",
"selector":"body"
},
{
"tagName":"text",
"selector":"label"
}
],
"id":"b18c4eca-48e7-4177-b9b0-84e7c5636ffa",
"direction":"R",
"z":2,
"siblingRank":0,
"attrs":{
"body":{
"stroke":"#EEEEEE",
"fill":"#EEEEEE"
},
"label":{
"text":"Основная тема 1"
},
"button":{
"x":10
},
"buttonSign":{
"strokeWidth":1.8,
"refX":15,
"d":"M 2 5 8 5"
}
}
},
{
"type":"standard.Link",
"source":{
"id":"d732ec65-ce1b-4562-a2fc-3faf191ae585"
},
"target":{
"id":"b18c4eca-48e7-4177-b9b0-84e7c5636ffa"
},
"id":"852a6006-7c68-4b14-86b1-ce4667d7badb",
"z":3,
"vertices":[
{
"x":347.1171875,
"y":38.75
},
{
"x":347.1171875,
"y":-16.5
}
],
"attrs":{
}
},
{
"type":"mindock.Node",
"position":{
"x":-302.5234375,
"y":-46.75
},
"size":{
"width":182.5234375,
"height":60.5
},
"angle":0,
"hidden":false,
"collapsed":false,
"depth":1,
"markup":[
{
"tagName":"g",
"selector":"buttonGroup",
"children":[
{
"tagName":"rect",
"selector":"button",
"attributes":{
"pointer-events":"visiblePainted"
}
},
{
"tagName":"path",
"selector":"buttonSign",
"attributes":{
"fill":"none",
"pointer-events":"none"
}
}
]
},
{
"tagName":"rect",
"selector":"body"
},
{
"tagName":"text",
"selector":"label"
}
],
"id":"922e107b-f372-40ed-9326-6b4d56883ad2",
"direction":"L",
"z":4,
"siblingRank":0,
"attrs":{
"body":{
"stroke":"#EEEEEE",
"fill":"#EEEEEE"
},
"label":{
"text":"Основная тема 2"
},
"buttonGroup":{
"refX":0
},
"button":{
"x":-30
},
"buttonSign":{
"strokeWidth":1.8,
"refX":-25,
"d":"M 2 5 8 5"
}
}
},
{
"type":"standard.Link",
"source":{
"id":"d732ec65-ce1b-4562-a2fc-3faf191ae585"
},
"target":{
"id":"922e107b-f372-40ed-9326-6b4d56883ad2"
},
"id":"8e3fe6f1-3955-4aa0-bbad-713233447662",
"z":5,
"vertices":[
{
"x":-60,
"y":38.75
},
{
"x":-60,
"y":-16.5
}
],
"attrs":{
}
},
{
"type":"mindock.Node",
"position":{
"x":407.1171875,
"y":63.75
},
"size":{
"width":183.046875,
"height":60.5
},
"angle":0,
"hidden":false,
"collapsed":false,
"depth":1,
"markup":[
{
"tagName":"g",
"selector":"buttonGroup",
"children":[
{
"tagName":"rect",
"selector":"button",
"attributes":{
"pointer-events":"visiblePainted"
}
},
{
"tagName":"path",
"selector":"buttonSign",
"attributes":{
"fill":"none",
"pointer-events":"none"
}
}
]
},
{
"tagName":"rect",
"selector":"body"
},
{
"tagName":"text",
"selector":"label"
}
],
"id":"d450766f-a5fd-49a8-bf77-ce533714bdc8",
"direction":"R",
"z":6,
"siblingRank":1,
"attrs":{
"body":{
"stroke":"#EEEEEE",
"fill":"#EEEEEE"
},
"label":{
"text":"Основная тема 3"
},
"button":{
"x":10
},
"buttonSign":{
"strokeWidth":1.8,
"refX":15,
"d":"M 2 5 8 5"
}
}
},
{
"type":"standard.Link",
"source":{
"id":"d732ec65-ce1b-4562-a2fc-3faf191ae585"
},
"target":{
"id":"d450766f-a5fd-49a8-bf77-ce533714bdc8"
},
"id":"ee8ae909-a85b-4eff-9fd8-c046cd070cb4",
"z":7,
"vertices":[
{
"x":347.1171875,
"y":38.75
},
{
"x":347.1171875,
"y":94
}
],
"attrs":{
}
},
{
"type":"mindock.Node",
"position":{
"x":-303.21875,
"y":63.75
},
"size":{
"width":183.21875,
"height":60.5
},
"angle":0,
"hidden":false,
"collapsed":false,
"depth":1,
"markup":[
{
"tagName":"g",
"selector":"buttonGroup",
"children":[
{
"tagName":"rect",
"selector":"button",
"attributes":{
"pointer-events":"visiblePainted"
}
},
{
"tagName":"path",
"selector":"buttonSign",
"attributes":{
"fill":"none",
"pointer-events":"none"
}
}
]
},
{
"tagName":"rect",
"selector":"body"
},
{
"tagName":"text",
"selector":"label"
}
],
"id":"02ba8087-3f38-4aba-b270-2f17442d04fc",
"direction":"L",
"z":8,
"siblingRank":1,
"attrs":{
"body":{
"stroke":"#EEEEEE",
"fill":"#EEEEEE"
},
"label":{
"text":"Основная тема 4"
},
"buttonGroup":{
"refX":0
},
"button":{
"x":-30
},
"buttonSign":{
"strokeWidth":1.8,
"refX":-25,
"d":"M 2 5 8 5"
}
}
},
{
"type":"standard.Link",
"source":{
"id":"d732ec65-ce1b-4562-a2fc-3faf191ae585"
},
"target":{
"id":"02ba8087-3f38-4aba-b270-2f17442d04fc"
},
"id":"c11068f5-05e4-44de-8801-e1b395375574",
"z":9,
"vertices":[
{
"x":-60,
"y":38.75
},
{
"x":-60,
"y":94
}
],
"attrs":{
}
}
]
} And after a calling of graph.fromJSON I see the nodes only (without link). I found that after graph.fromJSON all models have new ids. So I assume the links aren't shown cause they wrong ids (old). Could help me find the solution and load the graph from JSON? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think I have seen this before. There is nothing wrong with the When you create a custom shape by extending a class and you override the class Shape extends dia.Element {
initialize(...args) {
super(...args);
/* your code */
}
} Is it the case? |
Beta Was this translation helpful? Give feedback.
I think I have seen this before. There is nothing wrong with the
JSON
or thefromJSON()
graph method.When you create a custom shape by extending a class and you override the
initialize
method (or similar) make sure to pass all the arguments tosuper
.Is it the case?