Diagram Editor 初始化
本文介绍了在页面中显示 Diagram Editor 的流程。要初始化编辑器,您需要引入编辑器专用的源文件,并使用 DiagramEditor 实例。除此之外,初始化阶段与 Diagram 组件的初始化过程相同:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="../codebase/diagramWithEditor.js"></script>
<link rel="stylesheet" href="../codebase/diagramWithEditor.css">
</head>
<body>
<div id="editor_container"></div>
<script>
// 准备数据
const data = [
{ id: 1, x: 100, y: 40, text: "Start", type: "start", height: 50 },
{ id: 2, x: 100, y: 170, text: "Operation 1", type: "output" },
{ id: 3, x: 100, y: 300, text: "Operation 2", type: "input" },
{ from: 1, to: 2 },
{ from: 2, to: 3 }
// 更多对象
];
// 创建 Diagram Editor
const editor = new dhx.DiagramEditor("editor_container", {
// 配置选项
});
// 将数据加载到编辑器中
editor.parse(data);
</script>
</body>
</html>