<h4>Percentual de pessoas desempregadas em mais de 180 países de todas as regiões, em escala linear, baseados em dados mais recentes. Referência 01/05/2016.</h4>
<svg width="960" height="200"></svg>
<script src="https://d3js.org/d3.v4.0.0-alpha.33.min.js"></script>
<h4>Fonte: <a href="http://www.tradingeconomics.com/country-list/unemployment-rate" target="_blank">Trending Economics</a></h4>
@import url(https://fonts.googleapis.com/css?family=Inconsolata:400,700);
body {
font-family: 'Inconsolata';
margin: 0 5%;
font-weight: 400;
font-smoothing:antialiased;
line-height: 1.3em
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.axis text {
font: 20px 'Inconsolata';
}
.cells path {
fill: none;
pointer-events: all;
}
.cells{
fill:#faa61a;
}
.cells :hover circle {
fill: #000;
}
var svg = d3.select("svg"),
margin = {top: 40, right: 40, bottom: 40, left: 10},
width = svg.attr("width") - margin.left - margin.right,
height = svg.attr("height") - margin.top - margin.bottom;
var formatValue = d3.format(",d");
var x = d3.scaleLinear()
.rangeRound([0, width]);
var g = svg.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
d3.csv("https://raw.githubusercontent.com/voltdatalab/graficos/gh-pages/dados/desempregomundo.csv", type, function(error, data) {
if (error) throw error;
x.domain(d3.extent(data, function(d) { return d.value; }));
var simulation = d3.forceSimulation(data)
.force("x", d3.forceX(function(d) { return x(d.value); }).strength(1))
.force("y", d3.forceY(height / 2))
.force("collide", d3.forceCollide(5))
.stop();
for (var i = 0; i < 120; ++i) simulation.tick();
g.append("g")
.attr("class", "axis axis--x")
.attr("transform", "translate(0," + height + ")")
.call(d3.axisBottom(x).ticks(5, ".0f"));
svg.append("text")
.attr("class", "x label")
.attr("text-anchor", "end")
.attr("x", 195)
.attr("y", 183)
.text("%");
var cell = g.append("g")
.attr("class", "cells")
.selectAll("g").data(d3.voronoi()
.extent([[-margin.left, -margin.top], [width + margin.right, height + margin.top]])
.x(function(d) { return d.x; })
.y(function(d) { return d.y; })
.polygons(data)).enter().append("g");
cell.append("circle")
.attr("r", 5)
.attr("cx", function(d) { return d.data.x; })
.attr("cy", function(d) { return d.data.y; })
.attr("fill",function(d) { if(d.data.id === "Djibouti")return "red"; })
;
cell.append("path")
.attr("d", function(d) { return "M" + d.join("L") + "Z"; });
cell.append("title")
.text(function(d) { return d.data.id + "\n" + d.data.value + "%"; });
});
function type(d) {
if (!d.value) return;
d.value = +d.value;
return d;
}
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |