-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathscript.js
More file actions
61 lines (36 loc) · 1.43 KB
/
script.js
File metadata and controls
61 lines (36 loc) · 1.43 KB
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
console.log("Assignment 3");
//Set up drawing environment with margin conventions
var margin = {t:20,r:20,b:50,l:50};
var width = document.getElementById('plot').clientWidth - margin.l - margin.r,
height = document.getElementById('plot').clientHeight - margin.t - margin.b;
var plot = d3.select('#plot')
.append('svg')
.attr('width',width + margin.l + margin.r)
.attr('height',height + margin.t + margin.b)
.append('g')
.attr('class','plot-area')
.attr('transform','translate('+margin.l+','+margin.t+')');
//Initialize axes
//Consult documentation here https://github.com/mbostock/d3/wiki/SVG-Axes
var scaleX,scaleY;
var axisX;
var axisY;
//Start importing data
d3.csv('/data/world_bank_2012.csv', parse, dataLoaded);
function parse(d){
//Eliminate records for which gdp per capita isn't available
//Check "primary completion" and "urban population" columns
//if figure is unavailable and denoted as "..", replace it with undefined
//otherwise, parse the figure into numbers
return {
};
}
function dataLoaded(error, rows){
//with data loaded, we can now mine the data
//with mined information, set up domain and range for x and y scales
//Log scale for x, linear scale for y
//scaleX = d3.scale.log()...
//Draw axisX and axisY
//draw <line> elements to represent countries
//each country should have two <line> elements, nested under a common <g> element
}