-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFlowChart.html
38 lines (33 loc) · 1.28 KB
/
FlowChart.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.3.0/raphael.min.js"></script>
<script src="https://flowchart.js.org/flowchart-latest.js"></script>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FlowChart</title>
</head>
<body>
<button id="download">Download</button>
<div id="canvas"></div>
<script>
document.getElementById("download").onclick = function(e) {
const canvas = document.getElementById("canvas");
if (canvas.children.length > 0) {
const svgData = canvas.querySelector("svg").outerHTML;
var svgBlob = new Blob([svgData], {
type: "image/svg+xml;charset=utf-8"
});
var svgUrl = URL.createObjectURL(svgBlob);
var downloadLink = document.createElement("a");
downloadLink.href = svgUrl;
downloadLink.download = "flowchart.svg";
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}
}
</script>
</body>
</html>