-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo_autoscaling.html
89 lines (67 loc) · 2.27 KB
/
demo_autoscaling.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html>
<head>
<title>PicoGraphDemo</title>
<script src="picograph.js"></script>
</head>
<body style="font-family: Lucida Console, Monaco, monospace;">
<h1>PicoGraphDemo</h1>
<p>All graphs show the same values but using different scaling</p>
<hr />
<h2>No autoscaling: autoScaleMode=0</h2>
<!-- Canvas for the graph -->
<canvas
id="graphDemo1"
style="width: 900px; height:200px; border:2px solid #000000;"
>
</canvas>
<!-- div for legends/labels -->
<div id="graphLabels1"></div>
<hr />
<h2>Peak autoscaling: autoScaleMode=1</h2>
<!-- Canvas for the graph -->
<canvas
id="graphDemo2"
style="width: 900px; height:200px; border:2px solid #000000;"
>
</canvas>
<!-- div for legends/labels -->
<div id="graphLabels2"></div>
<hr />
<h2>Continues autoscaling: autoScaleMode=2</h2>
<!-- Canvas for the graph -->
<canvas
id="graphDemo3"
style="width: 900px; height:200px; border:2px solid #000000;"
>
</canvas>
<!-- div for legends/labels -->
<div id="graphLabels3"></div>
<script>
/* Create graph using picograph */
let increment = 0;
let demograph1 = new Graph("graphDemo1",
["Random Y0", "Random Y1"],
"°C", "graphLabels1", 5, 100, -100, true, true, 4, 10, 0);
let demograph2 = new Graph("graphDemo2",
["Random Y0", "Random Y1"],
"°C", "graphLabels2", 5, null, null, true, true, 4, 10, 1);
let demograph3 = new Graph("graphDemo3",
["Random Y0", "Random Y1"],
"°C", "graphLabels3", 5, null, null, true, true, 4, 10, 2);
/* Update values every 10 times per second */
setInterval(updateGraphs, 100);
function updateGraphs() {
/* Get new values */
yrand0 = Math.random() * 20 + Math.sin(increment) * 100;
yrand1 = Math.random() * 20 - Math.sin(increment) * 100;
/* Update graph */
demograph1.update([yrand0, yrand1])
demograph2.update([yrand0, yrand1])
demograph3.update([yrand0, yrand1])
/* Generate graph flux */
increment += 0.0025;
}
</script>
</body>
</html>