How can I create a AlloyUI DiagramBuilder from the

2019-08-09 01:51发布

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?

2条回答
倾城 Initia
2楼-- · 2019-08-09 02:17

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

var diagramBuilderJSON = diagramBuilder.toJSON();
new A.DiagramBuilder({ fields : diagramBuilderJSON.nodes }).render();
查看更多
放荡不羁爱自由
3楼-- · 2019-08-09 02:27

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
});
查看更多
登录 后发表回答