[ Launch: test ] 6de701bad93db462063aef9dbfa04bf6 by voltdatalab
-
-
Save sergiospagnuolo/6de701bad93db462063aef9dbfa04bf6 to your computer and use it in GitHub Desktop.
test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"test","endpoint":"","display":"svg","public":true,"require":[{"name":"d3.js","url":"https://d3js.org/d3.v4.0.0-alpha.33.min.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"index.html":{"default":true,"vim":false,"emacs":false,"fontSize":12},"graph":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url(https://fonts.googleapis.com/css?family=Inconsolata:400,700); | |
@import url(https://fonts.googleapis.com/css?family=Merriweather+Sans:400,300); | |
body { | |
font-family: 'Merriweather Sans', sans-serif; | |
margin: 0 5%; | |
font-weight: 400; | |
-webkit-font-smoothing:antialiased; | |
line-height: 1.3em | |
} | |
h1 { | |
font-family: 'Inconsolata', sans-serif; | |
text-transform: uppercase; | |
} | |
h4 { | |
font-size: 12px; | |
} | |
.main { | |
margin: 0 auto; | |
} | |
.axis path, | |
.axis line { | |
fill: none; | |
stroke: #000; | |
shape-rendering: crispEdges; | |
} | |
.axis text { | |
font: 14px 'Inconsolata'; | |
} | |
.cells path { | |
fill: none; | |
pointer-events: all; | |
} | |
.cells{ | |
fill:#a7000c; | |
} | |
.cells :hover circle { | |
fill: #000; | |
} | |
.main{ | |
max-width: 900px; | |
} | |
a { | |
color: #000; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="main"> | |
<h1>Desemprego</h1> | |
<p>Taxa de desemprego em mais de 180 países. <em>Dados de Maio/2016</em></p> | |
<svg viewBox="0 0 500 250" ></svg> | |
<script src="https://d3js.org/d3.v4.0.0-alpha.33.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3-legend/1.10.0/d3-legend.min.js"></script> | |
<h4>SOURCE: <a href="http://www.tradingeconomics.com/country-list/unemployment-rate" target="_blank">Trending Economics</a></h4> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var svg = d3.select("svg"), | |
margin = {top: 0, right: 40, bottom: 40, left: 10}, | |
width = 500, | |
height = 250 - 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/dividapibmundial.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", 118) | |
.attr("y", 229) | |
.style("font-size", "10px") | |
.text("%"); | |
svg.append("text") | |
.attr("class", "x label") | |
.attr("text-anchor", "end") | |
.attr("x", 130) | |
.attr("y", 30) | |
.style("font-size", "10px") | |
.text("Mediana"); | |
svg.append("rect") | |
.attr("x", 84) | |
.attr("y", 10) | |
.attr("width", 1) | |
.style("fill", "#ababab") | |
.attr("height", 200); | |
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", 4) | |
.attr("cx", function(d) { return d.data.x; }) | |
.attr("cy", function(d) { return d.data.y; }) | |
.attr("fill",function(d) { if(d.data.id === "Brasil")return "#faa61a"; if(d.data.region === "África")return "rgba(255, 224, 102, 0.3)"; if(d.data.region === "Americas")return "rgba(112, 193, 179, 0.3)"; if(d.data.region === "Europa")return "rgba(36, 123, 160, 0.3)"; if(d.data.region === "Ásia")return "rgba(80, 81, 79, 0.3)";if(d.data.region === "Oceânia")return "rgba(141, 153, 174, 0.3)"}) | |
; | |
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment