forked from microsoft/Quantum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
116 lines (106 loc) · 2.93 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
<!--
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>H₂ Simulation Demo</title>
<style>
.chart-container {
position: absolute;
width: calc(100vw - 2em);
height: calc(100vh - 6em);
top: 5em;
left: 1em;
overflow-x: hidden;
overflow-y: hidden;
}
.chart-heading {
position: absolute;
width: 100vw;
top: 0;
left: 0;
text-align: center;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-weight: 300;
}
</style>
</head>
<body style="-webkit-app-region: drag">
<h1 class="chart-heading">
H<sub>2</sub> Simulation Demo
</h1>
<div class="chart-container">
<canvas id="chartCanvas"></canvas>
</div>
<script>
"use strict"
// You can also require other files to run in this process
var renderer = require('./renderer.js')
var charts = require("chart.js")
var plotData = [];
var ctx = document.getElementById("chartCanvas").getContext("2d");
var chart = new charts.Chart(ctx, {
type: 'scatter',
data: {
datasets: [
{
showLine: true,
label: 'Estimated',
data: [],
fill: false,
borderColor: '#ff0000'
},
{
showLine: true,
label: 'Theory',
data: [],
fill: false
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
defaultFontFamily: "'Segoe UI', Tahoma, Geneva, Verdana, sans-serif",
scales: {
xAxes: [{
scaleLabel: {
display: true,
labelString: 'Bond Length'
}
}],
yAxes: [{
scaleLabel: {
display: true,
labelString: 'Energy'
}
}]
}
}
})
renderer.connectToSimulationServer((data) => {
plotData.push(data);
if (data.source == "theory") {
chart.data.datasets.forEach((dataset) => {
if (dataset.label == "Theory") {
var point = { x: data.bondLength, y: data.theoreticalEnergy }
dataset.data.push(point)
}
})
}
else if (data.source == "simulation") {
chart.data.datasets.forEach((dataset) => {
if (dataset.label == "Estimated") {
var point = { x: data.bondLength, y: data.estEnergy }
dataset.data.push(point)
}
})
}
chart.update()
});
</script>
</body>
</html>