Built with blockbuilder.org class with Alan
xxxxxxxxxx
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
// Feel free to change or delete any of the code you see in this editor!
var svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 500)
d3.csv("gapminder_avg.csv",function(dataWeLoaded) {
console.log(dataWeLoaded);
var xScale = d3.scaleLinear()
.domain([0,40000])
.range([100,800]);
var yScale = d3.scaleLinear()
.domain([30,80])
.range([400,100]);
var rScale = d3.scaleSqrt()
// .domain([0,1000000000])
.domain ([0,d3.max(dataWeLoaded, function(d) {return +d.population;})])
.range([0,100]);
svg.selectAll("circle")
.data(dataWeLoaded)
.enter()
.append("circle")
.attr("cy",function(d) { return yScale (+d.lifeexp);})
//return 500 - (d.lifeexp*6/100);})
.attr("cx",function(d) { return xScale (+d.gdp);})
//return 100 + (d.gdp/100);})
.attr("r", function(d) {return 1 + (d.population/10000000);})
.attr("fill-opacity",0.4)
.attr("stroke","gray")
.attr("stroke-width",0.5)
.attr("stroke-opacity",1)
.attr("fill",function (d) { return d.color })
/*
data.sort(function(a,b) { return +a.population > +b.population;})
.forEach(function(dataWeLoaded,i){
console.log(dataWeLoaded);
svg.append("text")
.text(innerdata.country)
.attr("y", 200+(i+10))
.attr("x", 120)
.attr("font-size", 8)
.attr("fill", '#000fff')
.attr("font-family", "sans-serif");
})
*/
})
</script>
</body>
https://d3js.org/d3.v4.min.js