-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.html
180 lines (170 loc) · 7.41 KB
/
test.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Test Blocks</title>
<link href='https://rawgit.com/mozilla/metrics-graphics/master/dist/metricsgraphics.css' rel='stylesheet' type='text/css'>
<link href='https://rawgit.com/dandehavilland/mg-line-brushing/master/dist/mg_line_brushing.css' rel='stylesheet' type='text/css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
<script src="https://d3js.org/d3.v4.js"></script>
<script src="https://rawgit.com/mozilla/metrics-graphics/master/dist/metricsgraphics.js"></script>
<!-- <script src="https://rawgit.com/dandehavilland/mg-line-brushing/master/dist/mg_line_brushing.js"></script> -->
<style type="text/css">
.linked {
width: 100%;
}
div.img-container {
width: 200px;
height: 200px;
position: relative;
margin-left: auto;
margin-right: auto;
overflow: hidden;
}
img.cropped {
position: absolute;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
#explorer {
z-index: 100;
position: absolute;
background-color: white;
border-style: solid;
}
#title {
display: flex;
align-items: center;
justify-content: center;
margin: 10px;
}
#output {
width: 200px;
height: 200px;
}
#code {
margin: 10px;
padding: 10px;
background-color: lightgray;
}
</style>
</head>
<body>
<div id="chart"></div>
<div id="legend"></div>
<div id="explorer">
<div id="title"></div>
<div class="img-container"><img id='output' class="cropped"></div>
<div id="code">
</div>
</div>
<script type="text/javascript">
function fetchHTTP(url, methood){
var request = new XMLHttpRequest(), response;
request.onreadystatechange = function () {
if (request.readyState === 4 && request.status === 200) {
response = request.responseText;
}
}
request.open(methood ? methood : 'GET', url, false);
request.send();
return response;
}
function parseQuery (qstr) {
var query = {};
var a = qstr.split('&');
for (var i in a) {
var b = a[i].split('=');
query[decodeURIComponent(b[0])] = decodeURIComponent(b[1]);
}
return query;
}
function getRandomColor() {
function c() {
var hex = Math.floor(Math.random()*256).toString(16);
return ("0"+String(hex)).substr(-2); // pad with zero
}
return "#"+c()+c()+c();
}
var cursorX;
var cursorY;
document.onmousemove = function(e){
cursorX = e.pageX;
cursorY = e.pageY;
}
window.onload = function(){
var query = parseQuery(window.location.search.slice(1));
if (query['test']) {
console.log('Opening',query['test']);
d3.json(query['test'], function(data) {
var datum = [];
var legend = [];
var colors = [];
var tests = [];
var srcs = [];
var titles = [];
for (var block in data) {
for (var index in data[block]) {
titles.push(index);
datum.push(data[block][index]['data']);
srcs.push(data[block][index]['output']);
tests.push(data[block][index]['test'])
legend.push(index);
colors.push(getRandomColor());
}
}
MG.data_graphic({
title: "Frame delta",
description: "This test was perform on a RaspberryPi",
data: datum,
width: "1000",
height: "600",
target: '#chart',
legend: legend,
colors: colors,
y_extended_ticks: true,
min_y_from_data: true,
x_accessor: 'sec',
y_accessor: 'val',
linked: true,
mouseover: function(d, i) {
// console.log(d,i,srcs[d['line_id']]);
var index = d['line_id']-1;
if (srcs[index] !== undefined ) {
var explorer = document.getElementById('explorer');
explorer.style.left = (cursorX+10)+'px';
explorer.style.top = (cursorY+10)+'px';
var image = document.getElementById('output');
if (image.src !== srcs[index]) {
image.src = srcs[index];
var code = ''
if (tests[index]['defines']) {
for (var define in tests[index]['defines']) {
code += '#define ' + define + ' ' + tests[index]['defines'][define] +'\n';
}
code += '\n';
}
if (tests[index]['blocks']) {
if (tests[index]['blocks']['color']) {
code += tests[index]['blocks']['color'];
}
}
document.getElementById('code').innerHTML = '<pre><code>'+code+'</pre></code>';
explorer.style.borderColor = colors[index];
var title = document.getElementById('title');
title.innerHTML = titles[index];
title.style.color = colors[index];
}
}
},
});
});
}
};
</script>
</body>
</html>