-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
49 lines (46 loc) · 1.42 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
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="js/d3.wordcloud.js"></script>
<script src="js/d3.layout.cloud.js"></script>
<script>
$(document).ready(function() {
$.ajax({
type: "GET",
url: "results.csv",
dataType: "text",
success: function(data) {processData(data);}
});
});
words = [];
function processData(allText) {
var allTextLines = allText.split(/\r\n|\n/);
var headers = allTextLines[0].split(',');
var lines = [];
for (var i=2; i<allTextLines.length; i++) {
var data = allTextLines[i].split(',');
if (data.length == headers.length) {
var tarr = [];
for (var j=0; j<headers.length; j++) {
tarr.push(data[j]);
}
words.push({
text: tarr[1],
size: tarr[0]
});
}
}
d3.wordcloud()
.size([1000, 1080])
.selector('#wordcloud')
.words(words)
.start();
}
</script>
</head>
<body>
<div id="wordcloud"></div>
</body>
</html>