-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphArray.html
35 lines (33 loc) · 1.16 KB
/
GraphArray.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
<!DOCTYPE html>
<html>
<head>
<title>SVG</title>
<meta charset = "utf-8" />
</head>
<body>
<h1 align="center">SVG 2D array to graph<br> </h1>
<div style="border: solid greenyellow .2em; background-color: khaki; width: 1000px; margin: 0 auto;">
<svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg">
<path id="s3" fill="none" stroke="blue"
d = "M 0,0 L "
/>
</svg>
</div>
<script>
let od = document.getElementById('s3').getAttribute('d');
let ar = new Array();
for(var i=0 ; i<75 ; i++){
ar.push([Math.floor((Math.random() * 200) + 1),
Math.floor((Math.random() * 100) + 1)]);
}
document.getElementById('s3').setAttribute('d', od + spacedXY(ar));
function spacedXY(arr){
let str = "";
for (var i=0 ; i < arr.length ; i++){
str += ' ' + arr[i][0].toString() + ',' + arr[i][1].toString();
}
return str;
}
</script>
</body>
</html>