-
Notifications
You must be signed in to change notification settings - Fork 0
/
table.js
38 lines (32 loc) · 921 Bytes
/
table.js
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
function draw_table()
{
var tabulate = function (data,columns) {
var table = d3.select('#menu3').append('table')
var thead = table.append('thead')
var tbody = table.append('tbody')
thead.append('tr')
.selectAll('th')
.data(columns)
.enter()
.append('th')
.text(function (d) { return d })
var rows = tbody.selectAll('tr')
.data(data)
.enter()
.append('tr')
var cells = rows.selectAll('td')
.data(function(row) {
return columns.map(function (column) {
return { column: column, value: row[column] }
})
})
.enter()
.append('td')
.text(function (d) { return d.value })
return table;
}
d3.csv('top.csv',function (data) {
var columns = ['title', 'coordinator', 'period','reference', 'programme','institute', 'organization', 'fund']
tabulate(data,columns)
})
}