-
Notifications
You must be signed in to change notification settings - Fork 1
/
mzqcreader.html
99 lines (74 loc) · 2.56 KB
/
mzqcreader.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
<html>
<body>
<form id="jsonFile" name="jsonFile" enctype="multipart/form-data" method="post">
<fieldset>
<h2>mzQC quick reader</h2>
<input type='file' id='fileinput'>
<input type='button' id='btnLoad' value='Load' onclick='loadFile();'>
</fieldset>
</form>
<div id="ms1tic" style="float:left;"></div>
<div id="ms2tic" style="float:left;"></div>
<div id="output"></div>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
var input, file, fr, newArr;
input = document.getElementById('fileinput');
output = document.getElementById('output');
function loadFile() {
if (typeof window.FileReader !== 'function') {
alert("This browser does not support this tool");
return;
}
if (!input.files) {
alert("This browser does not support this tool");
}
else if (!input.files[0]) {
alert("Please select a file before clicking 'Load'");
}
else {
file = input.files[0];
fr = new FileReader();
fr.onload = receivedText;
fr.readAsText(file);
}
function receivedText(e) {
let lines = e.target.result;
newArr = JSON.parse(lines);
newArr.mzQC.runQuality[0].qualityParameters.forEach(iterate);
var data = new google.visualization.DataTable();
data.addColumn('number', 'time');
data.addColumn('number', 'MS1');
data.addColumn('number', 'MS2');
data.addRows(Array.from(newArr.mzQC.runQuality[0].qualityParameters[31].value));
// Set chart options
var options = {'title':'TIC',
'width':800,
'height':600};
// Instantiate and draw our chart, passing in some options.
chart = new google.visualization.LineChart(document.getElementById('ms1tic'));
chart.draw(data, options);
}
function iterate(item) {
console.log("1");
var div = document.createElement("div");
var h3 = document.createElement("h3");
var p = document.createElement("p");
h3.innerHTML = item.name;
p.innerHTML = item.unit.name + " " + item.value;
div.appendChild(h3);
div.appendChild(p);
output.appendChild(div);
}
}
google.charts.load('current', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
}
</script>
</body>
</html>