-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo_updateconfig.html
56 lines (44 loc) · 1.32 KB
/
demo_updateconfig.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<title>PicoGraphDemo</title>
<script src="picograph.js"></script>
</head>
<body style="font-family: Lucida Console, Monaco, monospace;">
<h1>PicoGraphDemo</h1>
<!-- Canvas for the graph -->
<canvas
id="graphDemo"
style="width: 900px; height:200px; border:2px solid #000000;"
>
</canvas>
<!-- div for legends/labels -->
<div id="graphLabels"></div>
<script>
/* Create graph using picograph */
let demograph = new Graph("graphDemo",
["Random Y0", "Random Y1"],
"units", "graphLabels", 50, 10, 0, true, true);
/* Update values every second */
setInterval(updateEverySecond, 1000);
setTimeout(() => {
demograph.updateConfig(
["Random Y1", "Random Y2", "Random Y3"],
"cm",
25,
15,
0
)
demograph.setColors(["#00ff00", "#00ffff", "#ff0000"])
}, 5000)
function updateEverySecond() {
/* Get new values */
yrand0 = Math.random() * 10;
yrand1 = Math.random() * 10;
yrand2 = Math.random() * 10;
/* Update graph */
demograph.update([yrand0, yrand1, yrand2])
}
</script>
</body>
</html>