-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
255 lines (191 loc) · 7.82 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
<!-- William Skagerström, 2019-01-26 -->
<!DOCTYPE html>
<html>
<head>
<!--Using the google visualization API framework-->
<link rel="stylesheet" type="text/css" href="style.css">
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
// Load the Visualization API and the corechart package.
google.charts.load('current', {'packages':['corechart']});
// Runs when the Google Visualization API is loaded. Default Sum of skills and visualization skills.
google.charts.setOnLoadCallback(function() { drawChart('P', 'D'); });
</script>
<script type="text/javascript">
xattrib = ''; // X axis
yattrib = ''; // Y axis
filter = '' // Filter. Default set to none.
// Interest variables
games = 0;
programming = 0;
reading = 0;
music = 0;
art = 0;
movies = 0;
sports = 0;
function changeXAxis(x) {
drawChart(x, yattrib);
}
function changeYAxis(y) {
drawChart(xattrib, y);
}
function drawChart(x_value, y_value) {
xattrib = x_value;
yattrib = y_value;
var url = 'https://docs.google.com/spreadsheets/d/1EthJzVYQMrFN2BU6TbBRnzuWkz3pTzBCt9TVs0ADNSE/edit?usp=sharing';
var query = new google.visualization.Query(url);
var sqlquery = "SELECT A,"+xattrib+","+yattrib+",B " + filter
//console.log(sqlquery);
query.setQuery(sqlquery);
query.send(function (response) {
if (response.isError()) { // If the query returns an error message, display error
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
var dataTable = response.getDataTable();
var chart = new google.visualization.BubbleChart(document.querySelector('#chart_div'));
var options = {
title : 'Graph of student skills',
hAxis: {title: dataTable.getColumnLabel(1)},
vAxis: {title: dataTable.getColumnLabel(2)},
bubble: {
textStyle: {
fontSize: 8,
fontName: 'Arial',
bold: true,
color: 'black',
auraColor: 'white'
}
},
explorer: {} // Enables zooming, dragging etc
};
chart.draw(dataTable, options);
});
}
function interestFilter(interestValue) {
var interestsColumnsDesignations = ['Q', 'R', 'S', 'T', 'U', 'V', 'W']; // Boolean encoded interests(Column names)
// If on turn off, if off turn on
if (interestValue == 'programming') {
programming = (programming==1) ? 0 : 1;
}
if (interestValue == 'music') {
music = (music==1) ? 0 : 1;
}
if (interestValue == 'sports') {
sports = (sports==1) ? 0 : 1;
}
if (interestValue == 'games') {
games = (games==1) ? 0 : 1;
}
if (interestValue == 'art') {
art = (art==1) ? 0 : 1;
}
if (interestValue == 'reading') {
reading = (reading==1) ? 0 : 1;
}
if (interestValue == 'movies') {
movies = (movies==1) ? 0 : 1;
}
var interests = [programming, music, sports, games, art, reading, movies];
var sum = interests.reduce(function(a, b) { return a + b; }, 0); // Sums the values in interests
if (sum != 0) {
filter = 'WHERE ';
var count = 0; // For aligning the query with correct number of ANDs
for (var i = 0; i<interestsColumnsDesignations.length; i++) {
if (interests[i] == 1) {
count = count + 1;
if (count == sum) {
filter = filter + interestsColumnsDesignations[i] + ' = 1 ';
} else {
filter = filter + interestsColumnsDesignations[i] + ' = 1 AND ';
}
}
}
} else { // No boxes selected, use default filter(none)
filter = '';
}
//console.log(filter)
drawChart(xattrib, yattrib);
}
</script>
</head>
<body>
<!--Title -->
<div id="header">
<h2>IVIS Group Visualization</h2>
</div>
<!--Div that holds the visualization-->
<div id="chart_div" style="width: 1200px; height: 650px; "></div>
<!--Div for changing x-axis-->
<div id="x-axis" style="display:inline-block;margin-right:30px";>
<h4>X-axis attribute</h4>
<select name="numbers" onchange="changeXAxis(this.value)" size="1">
<option value='D' >Information Visualization skills</option>
<option value='E'>Statistical skills</option>
<option value='F'>Mathematics skills</option>
<option value='G'>Drawing and artistic skills</option>
<option value='H'>Computer usage skills</option>
<option value='I'>Programming skills</option>
<option value='J'>Graphics programming skills</option>
<option value='K'>Human-computer interaction programming skills</option>
<option value='L'>User experience evaluation skills</option>
<option value='M'>Communication skills</option>
<option value='N'>Collaboration skills</option>
<option value='O'>Code repository skills</option>
<option value='P'selected="selected" >Sum of skills</option>
</select>
</div>
<!--Div for changing y-axis-->
<div id="y-axis" style="display:inline-block;margin-right:0px";>
<h4>Y-axis attribute</h4>
<select name="numbers" onchange="changeYAxis(this.value)" size="1" >
<option value='D' >Information Visualization skills</option>
<option value='E'>Statistical skills</option>
<option value='F'>Mathematics skills</option>
<option value='G'>Drawing and artistic skills</option>
<option value='H'>Computer usage skills</option>
<option value='I'>Programming skills</option>
<option value='J'>Graphics programming skills</option>
<option value='K'>Human-computer interaction programming skills</option>
<option value='L'>User experience evaluation skills</option>
<option value='M'>Communication skills</option>
<option value='N'>Collaboration skills</option>
<option value='O'>Code repository skills</option>
<option value='P'>Sum of skills</option>
</select>
</div>
<!-- Div for changing data interest filters -->
<div id="filter" >
<h4>Interest Filters</h4>
Programming
<label class="switch">
<input type="checkbox" onclick="interestFilter('programming')">
</label>
Music
<label class="switch">
<input type="checkbox" onclick="interestFilter('music')">
</label>
Sports
<label class="switch">
<input type="checkbox" onclick="interestFilter('sports')">
</label>
Games
<label class="switch">
<input type="checkbox" onclick="interestFilter('games')">
</label>
Art/Design
<label class="switch">
<input type="checkbox" onclick="interestFilter('art')">
</label>
Writing/Reading
<label class="switch">
<input type="checkbox" onclick="interestFilter('reading')">
</label>
Movies
<label class="switch">
<input type="checkbox" onclick="interestFilter('movies')">
</label>
</div>
</body>
</html>