-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
430 lines (401 loc) · 16.9 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SpeckTackle Development</title>
<meta charset="UTF-8">
<!-- Main page CSS -->
<link rel="stylesheet" type="text/css" href="css/index.css">
<!-- SpeckTackle CSS containing chart stylings -->
<link rel="stylesheet" type="text/css" href="css/st.css">
<!-- SpeckTackle library -->
<script type="text/javascript", src="st.js"></script>
<!-- SpeckTackle dependencies -->
<script type="text/javascript", src="libs/d3/d3.js"></script>
<script type="text/javascript", src="libs/jquery/jquery.js"></script>
<script type="text/javascript">
// demonstration of SpeckTackle charts
var chart;
function ms (x) { // MS stub
$("#stgraph").empty(); // clear DOM child elements
$("#adddata").removeAttr("disabled") // enable 'Add Data' button
.attr("onclick","load(" + x + ")");// point to data loader
chart = st.chart // create a new MS chart
.ms() // chart type
.legend(true) // options
.xlabel("m/z")
.ylabel("Abundance")
.labels(true)
.margins([80, 80, 80, 120]);
chart.render("#stgraph"); // render chart to id 'stgraph'
};
function nmr (x) { // NMR stub
$("#stgraph").empty();
$("#adddata").removeAttr("disabled")
.attr("onclick","load(" + x + ")");
chart = st.chart
.nmr()
.legend(true)
.title("NMR")
.xlabel("ppm")
.labels(true)
.margins([80, 80, 80, 80]);
chart.render("#stgraph");
};
function nmr2d () { // NMR 2D stub
$("#stgraph").empty();
$("#adddata").removeAttr("disabled")
.attr("onclick","load(2)");
chart = st.chart
.nmr2d()
.xlabel("Chemical Shift (ppm)")
.ylabel("Chemical Shift (ppm)")
.margins([80, 120, 80, 80]);
chart.render("#stgraph");
};
function series () { // Chromatogram stub
$("#stgraph").empty();
$("#adddata").removeAttr("disabled")
.attr("onclick","load(3)");
chart = st.chart
.series()
.legend(true)
.labels(true)
.xlabel("Time [s]")
.ylabel("Abundance")
.title("Chromatogram")
.margins([80, 80, 80, 120]);
chart.render("#stgraph");
};
function irjdx () { // IR (JDX) stub
$("#stgraph").empty();
$("#adddata").removeAttr("disabled")
.attr("onclick","load(4)");
chart = st.chart
.ir()
.legend(true)
.xlabel("1/cm")
.ylabel("Transmittance")
.labels(true)
.title("Infrared Spectrum")
.margins([80, 120, 80, 120]);
chart.render("#stgraph");
};
function uvvisjdx () { // UV/VIS (JDX) stub
$("#stgraph").empty();
$("#adddata").removeAttr("disabled")
.attr("onclick","load(5)");
chart = st.chart
.series()
.legend(true)
.xreverse(true)
.xlabel("Wavelength [nm]")
.ylabel("Absorbance")
.title("UV/VIS Spectrum")
.margins([80, 120, 80, 120]);
chart.render("#stgraph");
};
function load (x) { // load chart data
switch (x) {
case 0: // MS
var set = st.data.set() // data type (set)
.ylimits([0, 1100]) // y-axis limits
.x("peaks.mz") // x-accessor
.y("peaks.intensity") // y-accessor
.title("spectrumId"); // id-accessor
// annotation structure
set.annotationColumn(st.annotation.ANNOTATION, "Ticks");
set.annotationColumn(st.annotation.TOOLTIP, "Origin");
set.annotationColumn(st.annotation.TOOLTIP_MOL, "Ion");
set.annotationColumn(st.annotation.TOOLTIP_MOL, "Frag");
chart.load(set); // bind the data set
set.add([ // input array
"resources/data1.json",
"resources/data2.json",
"resources/data3.json"
], [ // input annotation array
"resources/data1_anno.json",
"",
""
]);
break;
case 1: // NMR
var array = st.data.array() // data type (array)
.xlimits(["xMin", "xMax"])
.ylimits(["yMin", "yMax"])
.y("data") // one dimensional array
//.title("id");
chart.load(array);
array.add([
"resources/nmr1.json",
"resources/nmr2.json"
//"resources/nmr3.json"
//"resources/nmr4.json"
]);
break;
case 2: // NMR 2D
var set = st.data.set()
.x("data.x")
.y("data.y");
chart.load(set);
set.add("resources/nmr2d.json");
break;
case 3: // Chromatogram
var set = st.data.set()
.x("peaks.mz")
.y("peaks.intensity")
.title("spectrumId");
chart.load(set);
set.add([
"resources/data1.json",
"resources/data2.json",
"resources/data3.json"
]);
break;
case 4: // IR (JDX)
var array = st.data.array()
.xlimits(["FIRSTX", "LASTX"])
.ylimits(["MINY", "MAXY"])
.y("XYDATA")
.title("TITLE");
// annotation structure
array.annotationColumn(st.annotation.ANNOTATION, "Ticks");
array.annotationColumn(st.annotation.TOOLTIP, "Comment");
chart.load(array);
st.parser.jdx("resources/ir.jdx", function (jdx) {
array.add(
jdx,
[[
["a-series", 294, "*", "See Reference"],
["a-series", 687, "C=O", "See Reference"],
["a-series", 1284, "O-H stretch?", "See Reference"]
]]);
});
break;
case 5: // UV/VIS (JDX)
var array = st.data.array()
.xlimits(["LASTX", "FIRSTX"])
.ylimits(["MAXY", "MINY"])
.y("XYDATA")
.title("TITLE");
chart.load(array);
st.parser.jdx("resources/uvvis.jdx", function (jdx) {
array.add(jdx);
});
break;
case 6: // MS
var set = st.data.set()
.ylimits([0, 1000])
.x("peaks.mz")
.y("peaks.intensity")
.title("spectrumId");
chart.load(set);
set.add([
"resources/single_point_1.json"
]);
break;
case 7: // NMR
var array = st.data.array()
.xlimits(["xMin", "xMax"])
.y("data")
.title("id");
chart.load(array);
array.add([
"resources/single_point_2.json"
]);
break;
case 8: // difference chart
var set = st.data.set()
.x("data.x")
.y("data.y")
.title("id");
chart.load(set);
set.add([
"resources/difference.json"
]);
break;
case 9: // spectral match
var set = st.data.set()
.x("peaks.mz")
.y("peaks.intensity")
.title("spectrumId");
chart.load(set);
set.add([
"resources/data3.json",
"resources/data3_inv.json"
]);
break;
case 10: // PRIDE
var set = st.data.set()
.xlimits(["mzRangeStart", "mzRangeStop"])
.x("mzArray")
.y("intenArray")
.title("spectrumId");
// annotation structure
set.annotationColumn(st.annotation.ANNOTATION, "Series");
chart.load(set);
set.add([
"resources/pride.json"
], [
"resources/pride_anno.json"
]);
break;
};
$("#adddata").attr('disabled','disabled');
};
function dynamicms () { // dynamic MS stub
ms();
$("#adddata").attr('disabled','disabled');
var counter = 0;
var data = [
"resources/data1.json",
"resources/data2.json",
"resources/data3.json"
]
var set = st.data.set()
.ylimits([0, 1000])
.x("peaks.mz")
.y("peaks.intensity")
.title("spectrumId");
chart.load(set);
setTimeout(function iter() {
if (counter === 6) {
$("#dynamicload").html('');
return;
}
if (counter < 3) {
$("#dynamicload").html("Loading: " + data[counter]);
set.add(data[counter]);
} else {
$("#dynamicload").html("Removing: " + data[counter - 3]);
set.remove(0);
}
counter += 1;
setTimeout(iter, 1000);
}, 1000);
};
function dynamicnmr () { // dynamic NMR stub
nmr();
$("#adddata").attr('disabled','disabled');
var counter = 0;
var data = [
"resources/nmr1.json",
"resources/nmr2.json",
"resources/nmr3.json"
];
var array = st.data.array() // data type (array)
.xlimits(["xMin", "xMax"])
.ylimits(["yMin", "yMax"])
.y("data") // array is one dimensional
.title("id");
chart.load(array);
setTimeout(function iter() {
if (counter === 6) {
$("#dynamicload").html('');
return;
}
if (counter < 3) {
$("#dynamicload").html("Loading: " + data[counter]);
array.add(data[counter]);
} else {
$("#dynamicload").html("Removing: " + data[counter - 2]);
array.remove(0);
}
counter += 1;
setTimeout(iter, 1000);
}, 1000);
};
function multiplecharts () { // multiple charts stub
$("#stgraph").css("display", "none");
$("#stgraphm1").empty();
$("#stgraphm2").empty();
$("#stgraphm3").empty();
var chart1 = st.chart
.ms()
.legend(true)
.xlabel("m/z")
.ylabel("Abundance")
.title("Mass Spectrum")
.margins([80, 80, 80, 120]);
var chart2 = st.chart
.series()
.legend(true)
.xlabel("Time [s]")
.ylabel("Abundance")
.title("Chromatogram")
.margins([80, 80, 80, 120]);
var chart3 = st.chart
.nmr()
.legend(true)
.title("NMR")
.xlabel("ppm")
.margins([80, 80, 80, 80]);
chart1.render("#stgraphm1");
chart2.render("#stgraphm2");
chart3.render("#stgraphm3");
var set1 = st.data.set()
.ylimits([0, 1000])
.x("peaks.mz")
.y("peaks.intensity")
.title("spectrumId");
var set2 = st.data.set()
.ylimits([0, 1000])
.x("peaks.mz")
.y("peaks.intensity")
.title("spectrumId");
var set3 = st.data.set()
.ylimits([0, 1000])
.x("peaks.mz")
.y("peaks.intensity")
.title("spectrumId");
chart1.load(set1);
chart2.load(set2);
chart3.load(set3);
var data = [
"resources/data1.json",
"resources/data2.json",
"resources/data3.json"
];
set1.add(data);
set2.add(data);
set3.add(data);
};
</script>
</head>
<body>
<div id="wrap">
<h2>SpeckTackle: Development</h2>
<ul>
<li><button onclick="ms(0)">MS</button></li>
<li><button onclick="nmr(1)">NMR</button></li>
<li><button onclick="nmr2d()">NMR2D</button></li>
<li><button onclick="series()">Chromatogram</button></li>
<li><button onclick="irjdx()">IR (JDX)</button></li>
<li><button onclick="uvvisjdx()">UV/VIS (JDX)</button></li>
<li> → </li>
<li><button id="adddata" onclick="load()"
disabled="disabled">Add Data</button></li>
</ul>
<hr>
<ul>
<li><button onclick="multiplecharts()">Multiple Charts</button></li>
<li><button onclick="dynamicms()">Dynamic MS</button></li>
<li><button onclick="dynamicnmr()">Dynamic NMR</button></li>
<li><button onclick="ms(6)">Single Point MS</button></li>
<li><button onclick="nmr(7)">Single Point NMR</button></li>
<li id="dynamicload"></li>
</ul>
<hr>
<ul>
<li><button onclick="ms(8)">Difference Chart</button></li>
<li><button onclick="ms(9)">Spectral Match</button></li>
<li><button onclick="ms(10)">Peptide MS</button></li>
</ul>
<hr>
<!-- Container for all charts: '#stgraph' -->
<div id="stgraph" class="stgraph"></div>
<div id="stgraphm1" class="stgraphm"></div>
<div id="stgraphm2" class="stgraphm"></div>
<div id="stgraphm3" class="stgraphm"></div>
</div>
</body>
</html>