简体   繁体   English

如何从DiagramBuilder.toJSON()返回的JSON创建AlloyUI DiagramBuilder?

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

DiagramBuilder.toJSON() returns a JSON representation of the diagram. DiagramBuilder.toJSON()返回该图的JSON表示形式。 How can I use this JSON object to create a new DiagramBuilder with the same diagram? 如何使用此JSON对象创建具有相同图的新DiagramBuilder

You can pass the jsonData.nodes to the fields attribute of the DiagramBuilder : 您可以通过jsonData.nodesfields的属性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. 您可以将DiagramBuilder.toJSON()的结果传递给DiagramBuilder的fields参数。 See the example below. 请参见下面的示例。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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