-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
153 lines (117 loc) · 2.86 KB
/
index.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<html>
<head>
<title>SpectrumPlot2 example</title>
<style>
body {
margin: 0;
background-color: #ffcccc;
font-family: 'Roboto', sans-serif;
}
h1 {
margin-top: 10px;
width: 100%;
text-align: center;
font-size: 4em;
color: #ff4848;
margin-bottom: initial;
margin-top: 80px;
}
h2 {
margin-top: 10px;
width: 100%;
text-align: center;
font-size: 1em;
color: #ff4848;
}
a {
text-decoration: none;
color: #008fca;
transition: all 0.2s;
}
a:hover {
color: #00638c;
}
code {
font-family: "monospace";
background-color: #d49595;
padding: 0px 5px 0px 5px;
border-radius: 5px;
color: white;
}
#container {
margin-left: 25vw;
margin-right: 25vw;
}
#description {
text-align: center;
width: 100%;
}
#chartDiv {
padding: 20px;
background-color: #fafafa;
margin-top: 50px;
border-radius: 15px;
}
</style>
<!-- importing the automatically build module -->
<script src="../dist/SpectrumPlot2.js"></script>
</head>
<body>
<div id="container">
<h1>SpectrumPlot2</h1>
<h2><a href="https://github.com/jonathanlurie/SpectrumPlot2">fork it on Github</a></h2>
<div id="description">
Here, each spectrum's <code>Array</code> is updated with new values at every <code>mousemove</code>
<br>
Thus, calling <code>.updateSpectrum()</code> is NOT required.
</div>
<div id="chartDiv"></div>
</div>
<script>
var sp = new SpectrumPlot2.SpectrumPlot2( "chartDiv", 400, 300 );
var seriesSize = 100;
var redSeries = new Array(seriesSize);
var greenSeries = new Array(seriesSize);
var blueSeries = new Array(seriesSize);
var alphaSeries = new Array(seriesSize);
generateFakeData();
var redIndex = sp.addSpectrum(
"Red",
redSeries,
"rgba(250, 80, 80, 0.8)"
)
var greenIndex = sp.addSpectrum(
"Green",
greenSeries,
"rgba(80, 250, 80, 0.8)"
)
var blueIndex = sp.addSpectrum(
"Blue",
blueSeries,
"rgba(80, 80, 250, 0.8)"
)
var alphaIndex = sp.addSpectrum(
"Alpha",
alphaSeries,
"rgba(120, 120, 120, 0.8)"
)
sp.setLabels();
sp.draw();
function generateFakeData(){
for(var i=0; i<seriesSize; i++){
redSeries[i] = Math.random() * 10;
greenSeries[i] = Math.random() * 10 + 20;
blueSeries[i] = Math.random() * 10 + 40;
alphaSeries[i] = Math.random() * 10 + 60;
}
}
//addEventListener('mousemove', moveMouse, false);
function moveMouse(evt){
generateFakeData();
// In this case, no need to call updateSpectrum because
// we keep the same array (same reference)
sp.draw();
}
</script>
</body>
</html>