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