-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·209 lines (180 loc) · 8.22 KB
/
index.html
File metadata and controls
executable file
·209 lines (180 loc) · 8.22 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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/index.css">
<link rel="stylesheet" type="text/css" href="css/selector.css">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/d3-scale-chromatic.v1.min.js"></script>
<script src="https://d3js.org/topojson.v1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<title>CS 4802 | BioVis Final</title>
<script src="js/cluster.js"></script>
<script src="js/cloropleth.js"></script>
<script src="js/selector.js"></script>
<script src="js/happiness_barchart.js"></script>
</head>
<body >
<h1>Visualizing Happiness Around The World</h1>
<!-- year slider -->
<div align="center">
<div id="selector_div" align="center">
<p><b>drag</b> the sider to select the year that you would like to analyze</p>
<p><b>hover</b> over a country to view exact reported happyness value</p>
<p><b>click</b> on a country to get a closer look</p>
<p><b>Selected Year</b>: <span id="sliderVal"></span></p>
<input type="range" min="2008" max="2016" value="2016" step="1" class="slider" id="year_range" onchange="update_page(this.value)">
</div>
</div>
<br>
<!-- happiness map -->
<div class="Map" align="center"> </div>
<!-- cluster map -->
<div class="Cluster" align="center">
<span>
<p><b>The color of the ciricles corresponds to the happiness from the previous chart</b></p>
<p><b>hover</b> over a circle to view the country name and exact reported happyness value</p>
<p><b>Adjust</b> the siders to filter the cluster and find correlations</p>
<div id="sidebar">
<!-- happiness slider -->
<section class="range-slider">
<p id="happiness0" class="sidebarlabel"></p>
<input class="slider" id="happiness1" value="2.5" min="2.5" max="10" step="0.25" type="range" onchange="filter()">
<input class="slider" id="happiness2" value="10" min="2.5" max="10" step="0.25" type="range" onchange="filter()">
</section>
<!-- gdp slider 100,000-10,000,000,000,000,000 -->
<section class="range-slider">
<p id="gdp0" class="sidebarlabel"></p>
<input class="slider" id="gdp1" value="7" min="7" max="16" step="1" type="range" onchange="filter()">
<input class="slider" id="gdp2" value="16" min="7" max="16" step="1" type="range" onchange="filter()">
</section>
<!-- population slider 300000-2000000 -->
<section class="range-slider">
<p id="population0" class="sidebarlabel"></p>
<input class="slider" id="population1" value="16" min="16" max="29" step="1" type="range" onchange="filter()">
<input class="slider" id="population2" value="29" min="16" max="29" step="1" type="range" onchange="filter()">
</section>
<!-- inflation slider 50-20,000,000,000,000 -->
<section class="range-slider">
<p id="inflation0" class="sidebarlabel"></p>
<input class="slider" id="inflation1" value="6" min="6" max="35" step="1" type="range" onchange="filter()">
<input class="slider" id="inflation2" value="35" min="6" max="35" step="1" type="range" onchange="filter()">
</section>
<!-- unemployement slider 0-40 -->
<section class="range-slider">
<p id="unemployment0" class="sidebarlabel"></p>
<input class="slider" id="unemployment1" value="0" min="0" max="40" step="1" type="range" onchange="filter()">
<input class="slider" id="unemployment2" value="40" min="0" max="40" step="1" type="range" onchange="filter()">
</section>
<!-- alcohol slider 0-35 -->
<section class="range-slider">
<p id="alcohol0" class="sidebarlabel"></p>
<input class="slider" id="alcohol1" value="0" min="0" max="35" step="1" type="range" onchange="filter()">
<input class="slider" id="alcohol2" value="35" min="0" max="35" step="1" type="range" onchange="filter()">
</section>
</div>
<svg id="clusterSVG"></svg>
</span>
</div>
<div class="bar_holder" align = "center">
<p><b>The bars are sorted in assending order</b></p>
<p><b>hover</b> over a bar to view the country name and exact reported value of each field to learn more about each country</p>
<div class="happyness_bar" align="center"> </div>
<div class="population_bar" align="center"> </div>
<div class="gdp_bar" align="center"> </div>
<div class="inflation_bar" align="center"> </div>
<div class="unemployment_bar" align="center"> </div>
<div class="alcohol_bar" align="center"> </div>
</div>
<br>
<div align="center">
This project was created to determine what factors make people happy. Using a dataset where people ranked their own happiness and we decided we wanted to try to correlate that data to other factors, like the regions GPD, unemployment rate, alcohol consumption, etc, and try to determine what factors are most impactful on how someone ranks their own happiness. Using our visualization we present this information in a interactive, visually appealing, and informative manner for you to explore the connections between our variables. <br>
<br>
We found that there were many correlations between these datasets including happiness being inversely related to unemployment rates. We tried to allow users to make their own conclusions by allowing interactions with all of the datasets. <br>
<br>
To find more on how we completed this project
<a href="https://github.com/sjcomeau43543/DataVisFinal/blob/master/ProcessBook.pdf"> Click Here</a>
</div>
</body>
<script>
var slider = document.getElementById("year_range");
var output = document.getElementById("sliderVal");
output.innerHTML = slider.value;
slider.oninput = function() {
output.innerHTML = this.value;
}
</script>
<script>
var year = selector();
cloropleth(year);
cluster(year, get_filters());
happinessBar(year);
populationBar(year);
gdpBar(year);
inflationBar(year);
unemploymentBar(year);
alcoholBar(year);
// get the current filter values
function get_filters(){
var ids = ["happiness", "gdp", "population", "inflation", "unemployment", "alcohol"];
var filters = {};
for(var i=0; i<ids.length; i++){
var one, two;
if(ids[i] == "gdp"){
var power1 = document.getElementById(ids[i]+"1").value;
var power2 = document.getElementById(ids[i]+"2").value;
one = Math.pow(10, power1);
two = Math.pow(10, power2);
document.getElementById(ids[i]+"0").innerHTML = "gdp($): 10<sup>" + power1 + "</sup>-10<sup>" + power2 + "</sup>";
} else if(ids[i] == "population") {
var power1 = document.getElementById(ids[i]+"1").value;
var power2 = document.getElementById(ids[i]+"2").value;
one = Math.floor(3* Math.pow(2, power1));
two = Math.floor(3* Math.pow(2, power2));
document.getElementById(ids[i]+"0").innerHTML = "population: " + one + "-" + two;
} else if(ids[i] == "inflation") {
var power1 = document.getElementById(ids[i]+"1").value;
var power2 = document.getElementById(ids[i]+"2").value;
one = Math.floor(5* Math.pow(1.4, power1));
two = Math.floor(5* Math.pow(1.4, power2));
document.getElementById(ids[i]+"0").innerHTML = "inflation(index): " + one + "-" + two;
} else if (ids[i] == "alcohol"){
one = document.getElementById(ids[i]+"1").value;
two = document.getElementById(ids[i]+"2").value;
document.getElementById(ids[i]+"0").innerHTML = ids[i] + "(liters/year): " + one + "-" + two;
} else if (ids[i] == "happiness"){
one = document.getElementById(ids[i]+"1").value;
two = document.getElementById(ids[i]+"2").value;
document.getElementById(ids[i]+"0").innerHTML = ids[i] + ": " + one + "-" + two;
} else {
one = document.getElementById(ids[i]+"1").value;
two = document.getElementById(ids[i]+"2").value;
document.getElementById(ids[i]+"0").innerHTML = ids[i] + "(%): " + one + "-" + two;
}
// figure out which oen is larger
if (one*1.0 < two*1.0){
filters[ids[i]] = {"smaller":one, "larger":two};
} else if(one === two){
filters[ids[i]] = {"smaller":one, "larger":one};
} else {
filters[ids[i]] = {"smaller":two, "larger":one};
}
}
return filters;
}
function update_page(year){
year = selector();
cloropleth(year);
cluster(year, get_filters());
happinessBar(year);
populationBar(year);
gdpBar(year);
inflationBar(year);
unemploymentBar(year);
alcoholBar(year);
}
function filter() {
cluster(year, get_filters());
}
</script>
</html>