xxxxxxxxxx
<html lang="en">
<head>
<meta charset="utf-8">
<title>Global Gender Gap bart chart test</title>
<script type="text/javascript" src="https://d3js.org/d3.v3.js"></script>
<style type="text/css">
body {
background-color: white;
}
svg {
background-color: white;
}
</style>
</head>
<body>
<p> This chart shows WEF's 2014 Global Gender Gap Index values for a selected group of countries (The countries shown here have continuous data from 2000-2014. I hope to show change over time in future assignments). <p/>
<p> Highest score = 1 (equality)<p/>
<p> Lowest score = 0 (inequality)<p/>
<script type="text/javascript">
var svg = d3.select("body")
.append("svg")
.attr("width", 300)
.attr("height", 508);
//added own data set below, commmented out oriignal code below for future reference
d3.csv("WEFGenderGap_selected.csv", function(data) {
//d3.csv("betterlifeindex.csv", function(data) {
data.sort(function(a, b) {
//return d3.descending(a["2014", b["2014"]);
//If your numeric values aren't sorting properly,
//try commenting out the line above, and instead using:
//
return d3.descending(+a["2014"], +b["2014"]);
//
//Data coming in from the CSV is saved as strings (text),
//so the + signs here force JavaScript to treat those
//strings instead as numeric values, thereby fixing the
//sort order (hopefully!).
});
var rects = svg.selectAll("rect")
.data(data)
.enter()
.append("rect");
rects.attr("x", 0)
.attr("y", function(d, i) {
return i * 13;
})
.attr("width", function(d) {
return d["2014"] * 300;
})
.attr("height", 10)
.attr("height", 10)
.attr("fill", "teal")
.append("title")
.text(function(d) {
return d.Country + "'s gender gap index value in 2014 was " + d["2014"];
});
});
</script>
</body>
</html>
Modified http://d3js.org/d3.v3.js to a secure url
https://d3js.org/d3.v3.js