How can I create a AlloyUI DiagramBuilder from the JSON returned by DiagramBuilder.toJSON()?

谁都会走 提交于 2020-01-16 04:12:08

问题


DiagramBuilder.toJSON() returns a JSON representation of the diagram. How can I use this JSON object to create a new DiagramBuilder with the same diagram?


回答1:


You can pass the jsonData.nodes to the fields attribute of the DiagramBuilder:

var diagramBuilderJSON = diagramBuilder.toJSON();
new A.DiagramBuilder({ fields : diagramBuilderJSON.nodes }).render();



回答2:


You can pass the result of DiagramBuilder.toJSON() to the fields parameter of the DiagramBuilder. See the example below.

jsonData = DiagramBuilder.toJSON();
new Y.DiagramBuilder({
    fields : jsonData.nodes,
    availableFields: availableFields,
    boundingBox: '#diagram-builder-container',
    srcNode: '#diagramBuilder',
    render: true
});


来源:https://stackoverflow.com/questions/30787920/how-can-i-create-a-alloyui-diagrambuilder-from-the-json-returned-by-diagrambuild

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!