-
Notifications
You must be signed in to change notification settings - Fork 0
/
betsy-dashboard.html
342 lines (282 loc) · 9.98 KB
/
betsy-dashboard.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>betsy dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap-theme.min.css">
<script src="http://code.jquery.com/jquery.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="https://rawgithub.com/olimcc/gviz-pivottable/master/pivot2.js"></script>
<script type="text/javascript" src="results.js"></script>
<script type="text/javascript">
var results = [];
function loadAndParseCsvFile(filePath) {
var reader = new FileReader();
reader.onload = function (e) {
content = e.target.result;
updateResults(content);
}
reader.readAsText(filePath.files[0]);
}
function updateResults(csvContents) {
var rows = csvContents.trim().split("\n");
for(var i = 0; i < rows.length; i++) {
rows[i] = rows[i].split(";");
// adjust type from string to integer
rows[i][3] = parseInt(rows[i][3]);
rows[i][4] = parseInt(rows[i][4]);
rows[i][5] = parseInt(rows[i][5]);
}
results = rows;
drawTable();
}
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {packages:['table', 'corechart', 'controls']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawTable);
function create_ranking_data(data) {
return google.visualization.data.group(
data, [1],
[
{'column': 3, 'aggregation': google.visualization.data.sum, 'type': 'number'},
{'column': 0, 'aggregation': google.visualization.data.count, 'type': 'number'}
]
);
}
/**
* Draws the ranking of the engines as a table.
*/
function draw_ranking(data) {
var table = new google.visualization.Table(document.getElementById('grouped_table'));
table.draw(data, {showRowNumber : true, allowHtml: true});
return table;
}
function create_raw_data() {
var formatter = new google.visualization.ColorFormat();
formatter.addRange(0, 1, 'black', 'red');
formatter.addRange(1, 2, 'black', 'green');
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn("string", "Test");
data.addColumn("string", "Engine");
data.addColumn("string", "Group");
data.addColumn("number", "Successful?");
data.addColumn("number", "# of failed tests");
data.addColumn("number", "# of total tests");
data.addColumn("string", "success");
data.addRows(results);
formatter.format(data, 3);
return data;
}
function create_test_engine_data(raw_data_table) {
var formatter = new google.visualization.ColorFormat();
formatter.addRange(0, 1, 'black', 'red');
formatter.addRange(1, 2, 'black', 'green');
// A simple usage example
var test_engine_pivot = new gvizpivot.PivotAgg(
raw_data_table,
{pivotColumnIndex: {
column: 1,
sortDesc: true,
aggregator: google.visualization.data.sum // how to aggregate the pivoted values,
},
pivotKeyIndexes: [{column: 2},{column: 0}],
pivotValueIndex: {column: 3}
});
var test_engine_data_table = test_engine_pivot.getDataTable();
for(var i = 2; i < test_engine_data_table.getNumberOfColumns(); i++){
formatter.format(test_engine_data_table, i);
}
return test_engine_data_table;
}
function draw_test_engine(data) {
var table = new google.visualization.Table(document.getElementById('test_engine_table'));
table.draw(data, {showRowNumber : true, allowHtml: true});
return table;
}
function create_group_engine_data(data) {
var group_engine_pivot = new gvizpivot.PivotAgg(
data,
{pivotColumnIndex: {
column: 1,
sortDesc: true,
aggregator: google.visualization.data.sum // how to aggregate the pivoted values,
},
pivotKeyIndexes: [{column: 2}],
pivotValueIndex: {column: 3}
});
return group_engine_pivot.getDataTable();
}
function draw_group_engine(data) {
var table = new google.visualization.Table(document.getElementById('group_engine_table'));
table.draw(data, {showRowNumber : true, allowHtml: true});
return table;
}
function draw_raw(data){
return new google.visualization.ChartWrapper({
'chartType': 'Table',
'containerId': 'table',
'options': { allowHtml: true, showRowNumber: true }
});
}
function create_engine_group_data(data) {
return new gvizpivot.PivotAgg(
data,
{pivotColumnIndex: {
column: 2,
sortDesc: true,
aggregator: google.visualization.data.sum // how to aggregate the pivoted values,
},
pivotKeyIndexes: [{column: 1}],
pivotValueIndex: {column: 3}
}).getDataTable();
}
function draw_engine_group(data) {
var table = new google.visualization.Table(document.getElementById('engine_group_table'));
table.draw(data, {showRowNumber : true, allowHtml: true});
return table;
}
function draw_engine_group_bar_chart(data) {
var bar_chart = new google.visualization.BarChart(document.getElementById('engine_group_bar_chart'));
bar_chart.draw(data, {
width: 800,
height: 600,
hAxis: {title: "Successful tests"}
});
return bar_chart;
}
function drawTable() {
// Create and populate the data table.
var raw_data = create_raw_data();
var raw_table = draw_raw(raw_data);
var group_filter_control = create_group_filter_control();
var test_filter_control = create_test_filter_control();
var engine_filter_control = create_engine_filter_control();
var test_search_filter_control = create_test_search_filter_control();
var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard'));
// bind group -> test
dashboard.bind(group_filter_control, test_filter_control);
// bind test and test search -> table
dashboard.bind([test_filter_control, test_search_filter_control, engine_filter_control], raw_table);
// bind engine -> table
google.visualization.events.addListener(dashboard, 'ready', function() {
// update dependent charts
var current_raw_data = raw_table.getDataTable();
var engine_group_data = create_engine_group_data(current_raw_data);
var engine_group_table = draw_engine_group(engine_group_data);
var engine_group_bar_chart = draw_engine_group_bar_chart(engine_group_data);
var ranking_data = create_ranking_data(current_raw_data);
var ranking_table = draw_ranking(ranking_data);
var test_engine_data = create_test_engine_data(current_raw_data);
// set width of engine columns
for(var i = 2; i < test_engine_data.getNumberOfColumns(); i++){
test_engine_data.setProperty(0, i, 'style', test_engine_data.getProperty(0, i, 'style') + 'width:100px;');
}
var test_engine_table = draw_test_engine(test_engine_data);
var group_engine_data = create_group_engine_data(current_raw_data);
var group_engine_table = draw_group_engine(group_engine_data);
});
dashboard.draw(raw_data);
}
function create_group_filter_control() {
return new google.visualization.ControlWrapper({
'controlType': 'CategoryFilter',
'containerId': 'group_control',
'options': {
'filterColumnLabel': 'Group',
'ui': {
'labelStacking': 'vertical',
'allowTyping': false,
'allowMultiple': true
}
}
});
}
function create_test_filter_control() {
return new google.visualization.ControlWrapper({
'controlType': 'CategoryFilter',
'containerId': 'test_control',
'options': {
'filterColumnLabel': 'Test',
'ui': {
'labelStacking': 'vertical',
'allowTyping': false,
'allowMultiple': false
}
}
});
}
function create_engine_filter_control() {
return new google.visualization.ControlWrapper({
'controlType': 'CategoryFilter',
'containerId': 'engine_control',
'options': {
'filterColumnLabel': 'Engine',
'ui': {
'labelStacking': 'vertical',
'allowTyping': false,
'allowMultiple': true
}
}
});
}
function create_test_search_filter_control() {
return new google.visualization.ControlWrapper({
'controlType': 'StringFilter',
'containerId': 'test_filter',
'options': {
'filterColumnLabel': 'Test',
matchType: 'any'
}
});
}
</script>
<style>
.google-visualization-controls-categoryfilter { display: inline-block;}
.google-visualization-controls-stringfilter { display: inline-block;}
</style>
</head>
<body>
<div>
<span>Select results.csv file</span><input type="file" onchange="loadAndParseCsvFile(this)" />
</div>
<div>
<ul class="nav nav-tabs">
<li><a href="#dashboard" data-toggle="tab">Dashboard</a></li>
<li><a href="#rawdata" data-toggle="tab">Raw data</a></li>
<li><a href="#ranking" data-toggle="tab">Ranking</a></li>
<li><a href="#group_engine" data-toggle="tab">Group x Engine</a></li>
<li><a href="#engine_group" data-toggle="tab">Engine x Group</a></li>
</ul>
<div class="tab-content">
<div id="dashboard" class="tab-pane active">
<div id="controls">
<span id="group_control"></span>
<span id="test_control"></span>
<span id="engine_control"></span>
<span id="test_filter"></span>
</div>
<div id="test_engine_table"></div>
</div>
<div id="rawdata" class="tab-pane">
<div id="table"></div>
</div>
<div id="ranking" class="tab-pane">
<div id="grouped_table" ></div>
</div>
<div id="group_engine" class="tab-pane">
<div id="group_engine_table"></div>
</div>
<div id="engine_group" class="tab-pane">
<div id="engine_group_table"></div>
<div id="engine_group_bar_chart"></div>
</div>
</div>
</div>
</body>
</html>