-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
457 lines (407 loc) · 17 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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
<html>
<!-- No guarantee that this is the right place to place scripts. -->
<!-- But it works so I haven't changed it. -->
<!-- Chart.js utility classes, Chart.js itself -->
<script src="Utils.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<!-- https://old.reddit.com/r/learnjavascript/comments/msomp2/chartjs_actions/ -->
<!-- Data is ordered from 300 (first row) to 190 (last row) -->
<!-- So we use .slice() to create a deep copy and then .reverse() later on -->
<script src="data/5ugmL_16msDIT_1mm.js"></script>
<script src="data/5ugmL_16msDIT_10mm.js"></script>
<script src="data/5ugmL_125msDIT_1mm.js"></script>
<script src="data/5ugmL_125msDIT_10mm.js"></script>
<script src="data/5ugmL_2000msDIT_1mm.js"></script>
<script src="data/5ugmL_2000msDIT_10mm.js"></script>
<script src="data/50ugmL_16msDIT_1mm.js"></script>
<script src="data/50ugmL_16msDIT_10mm.js"></script>
<script src="data/50ugmL_125msDIT_1mm.js"></script>
<script src="data/50ugmL_125msDIT_10mm.js"></script>
<script src="data/50ugmL_2000msDIT_1mm.js"></script>
<script src="data/50ugmL_2000msDIT_10mm.js"></script>
<script src="data/500ugmL_16msDIT_1mm.js"></script>
<script src="data/500ugmL_16msDIT_10mm.js"></script>
<script src="data/500ugmL_125msDIT_1mm.js"></script>
<script src="data/500ugmL_125msDIT_10mm.js"></script>
<script src="data/500ugmL_2000msDIT_1mm.js"></script>
<script src="data/500ugmL_2000msDIT_10mm.js"></script>
<head>
<title>CD Spectroscopy Graph</title>
<meta charset="utf-8">
<meta name="viewport" content="width=1024">
<meta name="keywords" content="circular dichroism, spectroscopy">
<!-- Didn't include FB opengraph or twitter cards. -->
<meta name="author" content="Kaiwen Wang">
<link rel="stylesheet" href="graph.css">
<!-- Used for things like arrow dropdown -->
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500|Material+Icons" rel="stylesheet"
type="text/css">
<!-- First import might be unnecessary -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
</head>
<body>
<a class="github-link" href="https://github.com/kaiwen-wang/CD-Spectroscopy" title="Source on GitHub"
target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 60.5 60.5"
width="60" height="60">
<polygon class="bg" points="60.5,60.5 0,0 60.5,0 " />
<path class="icon"
d="M43.1,5.8c-6.6,0-12,5.4-12,12c0,5.3,3.4,9.8,8.2,11.4c0.6,0.1,0.8-0.3,0.8-0.6c0-0.3,0-1,0-2c-3.3,0.7-4-1.6-4-1.6c-0.5-1.4-1.3-1.8-1.3-1.8c-1.1-0.7,0.1-0.7,0.1-0.7c1.2,0.1,1.8,1.2,1.8,1.2c1.1,1.8,2.8,1.3,3.5,1c0.1-0.8,0.4-1.3,0.8-1.6c-2.7-0.3-5.5-1.3-5.5-5.9c0-1.3,0.5-2.4,1.2-3.2c-0.1-0.3-0.5-1.5,0.1-3.2c0,0,1-0.3,3.3,1.2c1-0.3,2-0.4,3-0.4c1,0,2,0.1,3,0.4c2.3-1.6,3.3-1.2,3.3-1.2c0.7,1.7,0.2,2.9,0.1,3.2c0.8,0.8,1.2,1.9,1.2,3.2c0,4.6-2.8,5.6-5.5,5.9c0.4,0.4,0.8,1.1,0.8,2.2c0,1.6,0,2.9,0,3.3c0,0.3,0.2,0.7,0.8,0.6c4.8-1.6,8.2-6.1,8.2-11.4C55.1,11.2,49.7,5.8,43.1,5.8z" />
</svg>
</a>
<!-- Header -->
<header>
<h1 class="l--page">Simulate <b>Circular Dichroism Spectroscopy</b> Results <br> Right Here in Your Browser.
</h1>
</header>
<div id="top-controls">
<div class="container l--page">
<section class="buttons">
</section>
<div class="control ui-concentration">
<label for="concentration">Concentration</label>
<div class="select">
<select id="concentration">
<option value="5">5 µg/mL</option>
<option value="50">50 µg/mL</option>
<option value="500">500 µg/mL</option>
</select>
</div>
</div>
<div class="control ui-integration">
<label for="integration">Integration Time</label>
<div class="select">
<select id="integration">
<option value="16">16 ms</option>
<option value="125">125 ms</option>
<option value="2000">2000 ms</option>
</select>
</div>
</div>
<div class="control ui-cuvette">
<label for="cuvette">Cuvette Width</label>
<div class="select">
<select id="cuvette">
<option value="1">1 mm</option>
<option value="10">10 mm</option>
</select>
</div>
</div>
</div>
</div>
<div id="main-part" class="l--page">
<div class="chart">
<canvas id="myChart"></canvas>
</div>
<div class="chart">
<canvas id="myChart_2"></canvas>
</div>
</div>
<!-- More -->
<div class="more">
<button class="mdl-button mdl-js-button mdl-button--fab"
onClick="document.getElementById('article-text').scrollIntoView({ behavior: 'smooth'});">
<i class="material-icons">keyboard_arrow_down</i>
</button>
</div>
<!-- Article -->
<article id="article-text">
<div class="l--body">
<h2>What even is Circular Dichroism Spectroscopy?</h2>
<p>It's a laboratory analytic technique that uses a circular dichroism spectrometer to measure the
difference between left circularly polarized light and right circularly polarized light in a sample.
It's commonly used to find the secondary structure of molecule and other parameters about a sample. You
can find more information about it at <a
href="https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Supplemental_Modules_(Physical_and_Theoretical_Chemistry)/Spectroscopy/Electronic_Spectroscopy/Circular_Dichroism">
Chemistry Libretexts
</a> or you could look for official documentation from JASKO, which is the producer of the equipment we
use
in our lab.
</p>
<p>
Undergrads who are working on multi-hour lab sessions may not know if
their data is correct or not. This tool help students see common errors with concentration, integration
time, cuvette size. The voltage chart on the right is a supplement to the data, letting people know
where data may or may not be faulty. Detailed instructions will be embedded in this page in the future.
</p>
</div>
<div class="l--body">
<h2>How was this made?</h2>
<p>
The data visualization uses <a href="https://www.chartjs.org/">Chart.js</a> to create the CD and voltage
graphs. The button logic is just raw Javascript while the CSS formatting comes from <a
href="https://playground.tensorflow.org">this open source project</a>. Material Design Lite is used
for the button styling.
</p>
<p>
As per the original license, this project is also licensed under the <a
href="https://github.com/tensorflow/playground/blob/master/LICENSE">Apache License</a>. Feel free to
use any of the chart data or visualization logic for derivative works.
</p>
</div>
<div class="l--body">
<h2>Credits</h2>
<p>
This site was built by <a href="https://www.kaiwenwang.me">Kaiwen Wang</a> part time over the Spring
2022 semester as part of a collaboration with Georgia Tech's <a href="https://ctl.gatech.edu/">Center
for Teaching and Learning</a>.
<br><br>
A big thanks goes to Dr. Mary Peek and Dr. Dexter Dean of Georgia Tech's chemistry department for their
help in explaining the theory behind this technique and collecting the data used for this visualization
and Dr. Vincent Spezzo as the department manager for CTL.
</p>
</div>
</article>
<!-- Footer -->
<footer>
<div class="l--body">
<div class="footer-center">
<a href="https://gatech.edu">
<img src="GTLogoSeal_Navy.png" alt="Georgia Tech Logo" width="200" class="logo">
</a>
<div class="links">
<a href="https://github.com/kaiwen-wang/CD-Spectroscopy">Source on GitHub</a>
</div>
</div>
</div>
</footer>
</body>
</html>
<!-- When the project got started it was a chart with a script tag in the main html file. Could refactor into ES6 modules just to learn some more.-->
<script>
const x = [...Array(111).keys()]; // Creates a range from 0 to 110
const labels = x.map(i => i + 190); // Makes it go from 190 to 300
const data = {
labels: labels,
datasets: [
{
label: '5, 16, 1',
data: _5ugmL_16msDIT_1mm_data.slice().reverse(),
borderColor: Utils.namedColor(0),
tension: 0.5,
borderJoinStyle: 'miter',
},
]
};
const data_2 = {
labels: labels,
datasets: [
{
label: '5, 16, 1',
data: _5ugmL_16msDIT_1mm_light.slice().reverse(),
borderColor: Utils.namedColor(0),
tension: 0.5,
borderJoinStyle: 'miter',
},
]
};
const config = {
type: 'line',
data: data,
options: {
animation: {
duration: 1000,
},
responsive: true,
plugins: {
legend: {
position: 'top',
labels: {
pointStyle: 'rectRounded',
usePointStyle: true
}
},
title: {
display: true,
text: 'CD Chart (Myoglobin)'
},
},
scales: {
x: {
ticks: {
autoSkip: true,
autoSkipPadding: 10,
maxTicksLimit: 12,
maxRotation: 0,
},
title: {
display: true,
text: "Wavelength (nm)"
},
suggestedMin: 190,
suggestedMax: 300
},
y: {
display: true,
title: {
display: true,
text: 'CD (mdeg)'
},
},
}
}
};
const config_2 = {
type: 'line',
data: data_2,
options: {
animation: {
duration: 1000,
},
responsive: true,
plugins: {
legend: {
position: 'top',
labels: {
pointStyle: 'rectRounded',
usePointStyle: true
}
},
title: {
display: true,
text: 'CD Voltage Charts (Myoglobin)'
},
},
scales: {
x: {
ticks: {
autoSkip: true,
autoSkipPadding: 10,
maxTicksLimit: 12,
maxRotation: 0,
},
color: "red",
display: true,
title: {
display: true,
text: "Wavelength (nm)"
},
suggestedMin: 190,
suggestedMax: 300
},
y: {
display: true,
title: {
display: true,
text: 'HT (V)'
},
// suggestedMin: -10,
// suggestedMax: 200
}
}
}
};
const actions = [
{
name: 'Add Dataset',
handler(chart, chart_2) {
// Selects value from dropdown menu "cuvette"
const concentration = document.getElementById('concentration').value;
const integration = document.getElementById('integration').value;
const cuvette = document.getElementById('cuvette').value;
// Selects the correct dataset using eval
const dataset_data = eval(`_${concentration}ugmL_${integration}msDIT_${cuvette}mm_data`);
const dataset_light = eval(`_${concentration}ugmL_${integration}msDIT_${cuvette}mm_light`);
const theColor = Utils.namedColor(chart.data.datasets.length);
const newDataset = {
label: concentration + ", " + integration + ", " + cuvette + "",
borderColor: theColor,
data: dataset_data.slice().reverse(),
tension: 0.5
};
const newDataset_2 = {
label: concentration + ", " + integration + ", " + cuvette + "",
borderColor: theColor,
data: dataset_light.slice().reverse(),
tension: 0.5
};
let flag = false;
chart.data.datasets.forEach((dataset) => {
if (dataset.label === newDataset.label) {
alert("Dataset already exists");
flag = true;
return;
}
});
if (!flag) {
chart.data.datasets.push(newDataset);
chart.update();
chart_2.data.datasets.push(newDataset_2);
chart_2.update();
}
}
},
{
name: 'Undo',
handler(chart, chart2) {
chart.data.datasets.pop();
chart.update();
chart2.data.datasets.pop();
chart2.update();
}
},
{
name: "Isolate Dataset",
handler(chart, chart2) {
// Selects value from dropdown menu "cuvette"
const concentration = document.getElementById('concentration').value;
const integration = document.getElementById('integration').value;
const cuvette = document.getElementById('cuvette').value;
// Selects the correct dataset using eval
const dataset_data = eval(`_${concentration}ugmL_${integration}msDIT_${cuvette}mm_data`);
const dataset_light = eval(`_${concentration}ugmL_${integration}msDIT_${cuvette}mm_light`);
theColor = Utils.namedColor(0);
const newDataset = {
label: concentration + ", " + integration + ", " + cuvette + "",
borderColor: theColor,
data: dataset_data.slice().reverse(),
tension: 0.5
};
const newDataset_2 = {
label: concentration + ", " + integration + ", " + cuvette + "",
borderColor: theColor,
data: dataset_light.slice().reverse(),
tension: 0.5
};
chart.data.datasets = [newDataset];
chart.update();
chart2.data.datasets = [newDataset_2];
chart2.update();
}
},
{
name: "Clear All",
handler(chart, chart2) {
chart.data.datasets = [];
chart.update();
chart2.data.datasets = [];
chart2.update();
}
},
// {
// name: "Download Dataset",
// }
];
// Progmatically creates buttons
actions.forEach((a, i) => {
let button = document.createElement("button");
button.classList.add("mdl-button", "mdl-js-button", "mdl-button--raised", "mdl-js-ripple-effect")
button.id = "button" + i;
// For add dataset action
button.innerText = a.name;
button.onclick = () => {
a.handler(myChart, myChart_2);
}
document.querySelector(".buttons").appendChild(button);
});
const myChart = new Chart(
document.getElementById('myChart'),
config
);
const myChart_2 = new Chart(
document.getElementById('myChart_2'),
config_2
);
</script>