$(function() {
var diagram = $("#diagram").dxDiagram({
contextMenu: {
enabled: true,
commands: ["bringToFront","sendToBack", "lock", "unlock"]
},
contextToolbox: {
enabled: true,
category: "flowchart",
shapeIconsPerRow: 5,
width: 200
},
propertiesPanel: {
visibility: 'visible',
tabs: [
{
groups: [ { title: "Page Properties", commands: ["pageSize", "pageOrientation", "pageColor"] } ]
}
]
},
historyToolbar: {
visible: false
},
viewToolbar: {
visible: true
},
mainToolbar: {
visible: true,
commands: [
{ name: "undo" },
{ name: "redo" },
{ name: "separator" },
{ name: "fontName" },
{ name: "fontSize" },
{ name: "separator" },
{ name: "bold" },
{ name: "italic" },
{ name: "underline" },
{ name: "separator" },
{ name: "fontColor" },
{ name: "lineColor" },
{ name: "fillColor" },
{ name: "separator" },
{ name: "clear", icon: "clearsquare", text: "Clear Diagram" }
]
},
toolbox: {
visibility: 'visible',
groups: [
"general", { category: "flowchart", title: "Flowchart", expanded: true }
],
showSearch: false,
shapeIconsPerRow: 4,
width: 220
},
onCustomCommand: function(e) {
if(e.name === "clear") {
var result = DevExpress.ui.dialog.confirm("Are you sure you want to clear the diagram? This action cannot be undone.", "Warning");
result.done(
function(dialogResult) {
if(dialogResult) {
e.component.import("");
}
}
);
}
}
}).dxDiagram("instance");
$.ajax({
url: "../../../../data/diagram-flow.json",
dataType: "text",
success: function(data) {
diagram.import(data);
}
});
});
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DevExtreme Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script>
<script src="https://cdn3.devexpress.com/jslib/20.2.6/js/dx-diagram.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.2.6/css/dx.common.css" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.2.6/css/dx.light.css" />
<link rel="stylesheet" href="https://cdn3.devexpress.com/jslib/20.2.6/css/dx-diagram.css" />
<script src="https://cdn3.devexpress.com/jslib/20.2.6/js/dx.all.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css" />
<script src="index.js"></script>
</head>
<body class="dx-viewport">
<div class="demo-container">
<div id="diagram">
</div>
</div>
</body>
</html>
#diagram {
height: 900px;
}