Skip to content

Instantly share code, notes, and snippets.

@ElBaston
Last active May 31, 2016 18:30
Show Gist options
  • Save ElBaston/16fbc4b173bff7f4b138784a1e05de79 to your computer and use it in GitHub Desktop.
Save ElBaston/16fbc4b173bff7f4b138784a1e05de79 to your computer and use it in GitHub Desktop.
Poland
Region Kinder Jugendliche Erwachsene Rentner lat lon Einwohner
Lodzkie 357553 333988 1464838 379487 51.55916 19.24856 2535866
Mazowieckie 798420 698882 2964503 755782 52.33116 20.87454 5217587
Malopolskie 533700 491587 1808181 447135 49.87607 20.19339 3280603
Slaskie 642966 622242 2671872 653550 50.45315 18.87503 4590630
Lubelskie 336790 322014 1191603 311272 51.25763 22.8301 2161679
Podkarpackie 343765 324722 1137550 275117 49.87607 22.08303 2081154
Swietokrzyskie 187293 180355 714939 189569 50.80161 20.65481 1272156
Podlaskie 180889 179188 641107 174967 53.16902 22.85208 1176151
Wielkopolskie 552378 501890 1950475 405978 52.35801 16.98538 3410721
Zachodniopomorskie 255495 236170 995481 209839 53.62755 15.44729 1696985
Lubuskie 157254 144424 588431 119496 52.18321 15.16165 1009605
Dolnoslaskie 406392 390466 1690848 388803 51.2026 16.21634 2876509
Opolskie 138276 140515 553872 142620 50.75993 17.82034 975283
Kujawsko-Pomorskie 326620 300774 1184471 262624 53.05031 18.50149 2074489
Warminsko-Mazurskie 232525 216431 810344 169196 53.82256 20.87454 1428496
Pomorskie 368824 324078 1267611 274442 54.23555 17.90823 2234955
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Scaled 3</title>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
body {
background: #333738;
}
background {
fill: none;
pointer-events: all;
}
PolenReg2 {
cursor: pointer;
}
path {
stroke: #000;
stroke-width: 1px;
}
path:hover {
fill: #386cb0;
}
.Kreisdiagramm {
fill: brown;
fill-opacity: .5;
stroke: #fff;
stroke-width: .5px;
}
.Kreisdiagramm :hover {
stroke: #000;
}
.PolenReg2 :hover {
fill: #386cb0;
}
.tooltip {
position: absolute;
top: 10px;
left: 10px;
background: #fff;
padding: 5px;
}
</style>
</head>
<body>
<script type="text/javascript">
//Width and height
var w = 1300;
var h = 1000;
//Define map projection
var projection = d3.geo.mercator()
.center([20, 54])
.scale(25000)
.rotate([0, 0]);
//Define path generator
var path = d3.geo.path()
.projection(projection);
var color = d3.scale.quantize().range(["#f7f7f7", "#cccccc", "#969696", "#636363", "#252525"]);
//Colors taken from colorbrewer.js, included in the D3 download
//Create SVG element
var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
var tooltip = d3.select("body").append("div").attr("class", "tooltip");
//Load in Cloropeth Data
d3.csv("Jugendarbeitslosigkeit.csv", function(data) {
//Set input domain for color scale
color.domain([
d3.min(data, function(d) {
return d.Jugendarb2000;
}),
d3.max(data, function(d) {
return d.Jugendarb2000;
})
]);
//Load in GeoJSON data
d3.json("PolenReg2.json", function(json) {
//Merge the ag. data and GeoJSON
//Loop through once for each ag. data value
for (var i = 0; i < data.length; i++) {
//Grab state name
var dataRegion = data[i].region;
//Grab data value, and convert from string to float
var dataValue = parseFloat(data[i].Jugendarb2000);
//Find the corresponding state inside the GeoJSON
for (var j = 0; j < json.features.length; j++) {
var jsonRegion = json.features[j].properties.name_alt;
if (dataRegion == jsonRegion) {
//Copy the data value into the JSON
json.features[j].properties.value = dataValue;
//Stop looking through the JSON
break;
}
}
}
//Bind data and create one path per GeoJSON feature
svg.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path)
.on("mouseover", function(d) {
tooltip.html(d.properties.name_alt);
})
.on("mouseout", function(d) {
tooltip.html("");
})
.style("fill", function(d) {
//Get data value
var value = d.properties.value;
if (value) {
//If value exists…
return color(value);
} else {
//If value is undefined…
return "#ccc";
}
});
//Big pie: Gesamtbevölkerung
d3.csv("Bevoelkerung-Altersstruktur-2010-Summe.csv", function drawPies(data) {
var pie = d3.layout.pie()
.sort(null)
.value(function(d) {
return +d
});
var arc = d3.svg.arc()
.innerRadius(0)
.outerRadius (40);
var pies = svg.selectAll('.pie')
.data(data)
.enter()
.append('g')
.attr('class', 'pie')
.attr("transform", function(d) {
return "translate(" + projection([d.lon, d.lat])[0] + "," + projection([d.lon, d.lat])[1] + ")";
});
var color = d3.scale.ordinal()
.range(["#98abc5", "#7b6888", "#a05d56", "#d0743c", ])
.domain(d3.range(0, 4));
pies.selectAll('.slice')
.data(function(d) {
return pie([d.Kinder, d.Jugendliche, d.Erwachsene, d.Rentner]);
})
.enter()
.append('path')
.attr('d', arc)
.style('fill', function(d, i) {
return color(i);
});
//Small pie: Auswanderer
d3.csv("Bevoelkerung-Altersstruktur-2010-Summe.csv", function drawPies2(data) {
var arc2 = d3.svg.arc().innerRadius(0).outerRadius(20);
var degree = Math.PI / 180;
var pie2 = d3.layout.pie()
.sort(null)
.value(function(d) {
return d
})
.startAngle(0 * degree).endAngle(180 * degree);
var pies2 = svg.selectAll('.pie2')
.data(data)
.enter()
.append('g')
.attr('class', 'pie')
.attr("transform", function(d) {
return "translate(" + projection([d.lon, d.lat])[0] + "," + projection([d.lon, d.lat])[1] + ")";
});
var color2 = d3.scale.ordinal()
.range(["#3182bd", "#7b4173", "#d62728", "#e6550d", ])
.domain(d3.range(0, 4));
pies2.selectAll('.slice')
.data(function(d) {
return pie2([d.Kinder, d.Jugendliche, d.Erwachsene, d.Rentner]);
})
.enter()
.append('path')
.attr('d', arc2)
.style('fill', function(d, i) {
return color2(i);
});
});
});
});
});
</script>
</body>
</html>
region Jugendarb1999 Jugendarb2000 Jugendarb2001 Jugendarb2002 Jugendarb2003 Jugendarb2004 Jugendarb2005 Jugendarb2006 Jugendarb2007 Jugendarb2008 Jugendarb2009 Jugendarb2010 Jugendarb2011 Jugendarb2012 Jugendarb2013 Jugendarb2014 Jugendarb2015
Lodzkie 26.0 41.2 41.1 41.9 39.2 38.5 33.1 25.0 17.8 16.8 19.1 21.3 23.6 28.3 23.8 20.1 20.6
Mazowieckie 22.6 32.0 31.5 31.2 36.3 34.6 31.9 28.6 21.3 14.9 14.9 19.1 22.6 19.4 19.3 17.7 18.5
Malopolskie 30.9 27.6 33.6 35.2 40.0 41.4 36.7 30.2 24.2 19.0 24.2 21.5 22.9 27.7 30.9 24.8 20.9
Slaskie 23.0 34.1 40.6 43.8 49.1 44.1 38.8 29.8 17.5 17.2 18.3 24.0 24.2 22.3 25.6 22.2 18.5
Lubelskie 31.9 34.9 36.1 36.2 36.1 37.5 30.3 32.1 24.3 24.5 26.9 26.1 31.9 30.9 31.0 33.2 29.0
Podkarpackie 43.3 41.6 44.7 40.0 40.5 35.4 43.3 35.3 24.4 21.6 33.1 35.3 36.6 40.8 43.5 41.1 38.4
Swietokrzyskie 33.4 40.3 49.1 51.3 45.4 39.8 43.6 36.6 27.8 20.2 23.9 28.2 34.4 31.2 32.2 26.8 25.8
Podlaskie 26.5 30.9 37.7 34.4 32.1 33.5 30.6 29.9 19.7 15.3 17.4 24.5 25.0 24.3 25.8 27.0 18.5
Wielkopolskie 24.9 32.9 38.5 40.9 37.9 36.4 34.9 27.1 19.3 12.7 17.8 21.8 23.3 22.9 21.9 20.7 16.2
Zachodniopomorskie 53.1 46.2 44.6 59.4 48.9 39.1 41.7 32.4 24.5 21.9 24.5 30.9 32.9 31.6 32.2 25.1 23.3
Lubuskie 26.1 35.4 47.4 45.1 49.7 52.5 35.3 29.3 25.1 15.7 23.5 24.3 25.7 26.4 27.8 27.2 :
Dolnoslaskie 35.5 42.1 44.0 47.7 45.2 48.7 45.0 32.8 22.8 19.9 23.3 23.8 24.5 29.8 30.1 23.5 17.2
Opolskie 32.3 31.4 43.0 44.3 44.8 42.5 36.1 29.1 18.3 16.6 20.3 21.5 21.3 22.7 21.8 19.9 16.6
Kujawsko-Pomorskie 31.0 38.1 40.1 45.5 41.7 39.9 39.1 31.1 22.9 19.0 21.5 25.4 28.3 30.5 32.3 26.6 18.6
Warminsko-Mazurskie 45.2 41.2 47.9 53.0 50.1 47.4 39.9 33.5 25.1 16.0 18.8 24.0 27.6 29.3 28.8 25.4 24.1
Pomorskie 16.4 33.6 32.6 44.4 39.4 36.2 36.3 27.3 20.8 11.3 16.2 21.0 22.0 24.1 26.5 21.6 18.6
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment