-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.js
73 lines (70 loc) · 1.43 KB
/
demo.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
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
var map = d3.select(".dashboard .map")
.append("svg"),
heading = d3.select(".dashboard h2"),
canada = window.getCanadaMap(map, {
/*provinces: ["ON", "QC"],*/
})
.on("loaded", function() {
window.console.log("loaded");
})
.on("zoom", function(province) {
var text = "Canada";
if (province){
switch(province) {
case "ON":
text = "Ontario";
break;
case "QC":
text = "Quebec";
break;
case "NS":
text = "Nova Scotia";
break;
case "NB":
text = "New Brunswick";
break;
case "MB":
text = "Manitoba";
break;
case "BC":
text = "British Columbia";
break;
case "PE":
text = "Prince Edward Island";
break;
case "SK":
text = "Saskatchewan";
break;
case "AB":
text = "Alberta";
break;
case "NL":
text = "Newfoundland and Labrador";
break;
case "NT":
text = "Northwest Territories";
break;
case "YT":
case "YK":
text = "Yukon";
break;
case "NU":
text = "Nunavut";
break;
}
}
heading.text(text);
window.console.log("Zoom:" + text);
});
setInterval(function() {
var provinces = Object.keys(canada.provinces),
provincesLength = provinces.length,
show = Math.floor(Math.random() * (provincesLength + 1)),
province;
if (show < provincesLength){
province = provinces[show];
canada.provinces[province].zoom();
} else {
canada.zoom();
}
}, 2000);