forked from MoravianUniversity/moraviancollege.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapManager.js
116 lines (87 loc) · 3.06 KB
/
mapManager.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
function mapManager() {
this.mapList = [];
this.current_gradient = 2;
this.mapCounter = 0;
var newThis = this;
this.maps = function() {
return newThis.mapList;
}
this.addMap = function(map) {
this.mapCounter ++;
map.setManager(this);
this.mapList.push(map);
if(this.mapList.length != 1){
for(var i = 0; i < this.mapList.length - 1; i += 1){
this.mapList[i].addObserver(this.mapList[this.mapList.length - 1]);
this.mapList[this.mapList.length - 1].addObserver(this.mapList[i]);
}
}
return this;
};
this.drawMaps = function(){
var scale;
var column_width;
var column_margin;
if (this.mapCounter == 1) {
scale = 1;
column_width = "row";
column_margin = " auto";
} else {
scale = 0.65;
column_width = "col-md-7 col-md-offset-1";
column_margin = " 2.5%"
}
for(var i = 0; i < this.mapList.length; i += 1){
console.log(scale);
this.mapList[i].setScaler(scale, column_width, column_margin);
console.log(this.mapList[i].svgScaler);
this.mapList[i].setup();
this.mapList[i].drawMap();
}
};
this.setMapColors = function(min_color, max_color){
for(var i = 0; i < this.mapList.length; i += 1){
this.mapList[i].setColors(min_color, max_color);
this.mapList[i].change_gradient(this.mapList[i].current_gradient);
}
}
this.makeCombo = function() {
var combo = d3.select("#comboDiv")
.append("select")
.attr("id", "color-selector")
.style("right-margin", "50%");
var i = 2;
while (i <= 10) {
combo.append("option")
.attr("id", "option" + i.toString())
.attr("value", i)
.text(i);
i += 1
}
combo.append("option")
.attr("id", "optionc")
.attr("value", -1)
.text("continuous");
if(newThis.current_gradient == -1) {
d3.select("#optionc")
.attr("selected", "selected");
}
else {
d3.select("#option" + newThis.current_gradient.toString())
.attr("selected", "selected");
}
d3.select("select").on("change", function() {
var value = this.options[this.selectedIndex].value;
for(var i = 0; i < newThis.mapList.length; i += 1) {
newThis.mapList[i].change_gradient(value);
newThis.mapList[i].current_gradient = value;
};
});
};
this.redraw = function() {
for (var i = 0; i < this.mapList.length; i += 1) {
this.mapList[i].setColors(String(getColor("min_color_picker")), String(getColor("max_color_picker"))).drawMap();
};
};
return this;
};