Data from the World Bank (download). Uses d3js.
xxxxxxxxxx
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.bar {
fill: steelblue;
}
.x.axis path {
display: none;
}
.legend line {
stroke: #000;
shape-rendering: crispEdges;
}
</style>
<body>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script>
var width = 960,
height = 500,
radius = Math.min(width, height) / 2;
var color = d3.scale.ordinal()
.range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]);
var arc = d3.svg.arc()
.outerRadius(radius - 10)
.innerRadius(radius - 100);
var pie = d3.layout.pie()
.sort(null)
.value(function(d) { return d.pop; });
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
var tooltip = svg.append('g')
.attr('transform', 'translate(' + 0 + ',' + 0 + ')')
.append('text')
.attr('text-anchor', 'middle');
svg
.on('mouseover', function() {
var d = d3.select(d3.event.target);
if (d) d = d.data()[0];
if (d && d.data && d.data.Economy) tooltip.text(d.data.Economy + ': ' +
d3.format(',')(d.data.pop) + ' (' + (100 * d.data.pop / total).toFixed(1) + '%)');
})
.on('mouseout', function() {
tooltip.text('');
})
d3.csv("pop.csv", function(error, data) {
data.forEach(function(d) {
d.pop = +(d.pop.replace(/\,/g, '')) * 1000;
});
total = data.reduce(function(mem, d) {
return mem + d.pop;
}, 0);
var g = svg.selectAll(".arc")
.data(pie(data))
.enter().append("g")
.attr('title', function(d) { return d.data.Country; })
.attr("class", "arc");
g.append("path")
.attr("d", arc)
.style("fill", function(d) { return color(d.data.Country); });
g.append("text")
.attr("transform", function(d) { return "translate(" + arc.centroid(d) + ")"; })
.attr("dy", ".35em")
.style("text-anchor", "middle")
.text(function(d) {
return (d.endAngle - d.startAngle > 0.1) ? d.data.Country : '';
});
});
</script>
Modified http://d3js.org/d3.v3.min.js to a secure url
https://d3js.org/d3.v3.min.js