-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmap.js
More file actions
69 lines (56 loc) · 1.5 KB
/
Copy pathmap.js
File metadata and controls
69 lines (56 loc) · 1.5 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
61
62
63
64
65
var year = 2005;
var startYear = 1990;
var endYear = 2007;
function map() {
var fill = pv.Scale.linear()
.domain(0, 100)
.range("#91bfdb", "#ffffbf", "#fc8d59");
countries.forEach(function(c) {
var country = countryCodeMap.twoToThree[c.code];
var y = forest[country];
c.color = y ? fill(y[0].value) : "#CCC";
});
var w = 860,
h = 3 / 5 * w,
geo = pv.Geo.scale("hammer").range(w, h);
var vis = new pv.Panel()
.width(w)
.height(h);
/* Countries. */
vis.add(pv.Panel)
.data(countries)
.add(pv.Panel)
.data(function(c) { return c.borders;})
.add(pv.Line)
.data(function(b) { return b; })
.left(geo.x)
.top(geo.y)
.title(function(d, b, c) { return c.name;})
.fillStyle(function(d, b, c) {return c.color;})
.strokeStyle(function() { return this.fillStyle() ? this.fillStyle().darker() : this.fillStyle();})
.lineWidth(1)
.antialias(false);
/* Latitude ticks. */
vis.add(pv.Panel)
.data(geo.ticks.lat(500))
.add(pv.Line)
.data(function(b) { return b;})
.left(geo.x)
.top(geo.y)
.strokeStyle("rgba(128,128,128,.3)")
.lineWidth(1)
.interpolate("cardinal")
.antialias(false);
/* Longitude ticks. */
vis.add(pv.Panel)
.data(geo.ticks.lng(500))
.add(pv.Line)
.data(function(b) { return b;})
.left(geo.x)
.top(geo.y)
.strokeStyle("rgba(128,128,128,.3)")
.lineWidth(1)
.interpolate("cardinal")
.antialias(false);
vis.render();
}