简体   繁体   中英

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

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?

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

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

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
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM