Last active
August 29, 2015 14:25
-
-
Save junkwhinger/3bd8a0856d74034ff257 to your computer and use it in GitHub Desktop.
OECD-service_hc
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<header>OECD Better Life Index 2015 World Map (Mercator)</header> | |
<style> | |
header { | |
display: none; | |
} | |
body { | |
background: #fcfcfa; | |
} | |
.stroke { | |
fill: none; | |
stroke: #000; | |
stroke-width: 3px; | |
} | |
.fill { | |
fill: #fff; | |
} | |
.graticule { | |
fill: none; | |
stroke: #777; | |
stroke-width: .5px; | |
stroke-opacity: .5; | |
} | |
.land { | |
fill: #222; | |
} | |
.country:hover { | |
opacity: 0.8; | |
} | |
.boundary { | |
fill: none; | |
stroke: #fff; | |
stroke-width: .5px; | |
} | |
.tooltip{ background-color:rgba(68,136,187,0.5);; | |
margin: 10px; | |
height: 50px; | |
width: 150px; | |
padding-left: 10px; | |
padding-top: 10px; | |
-webkit-border-radius:10px; | |
-moz-border-radius:10px; | |
border-radius:10px; | |
} | |
</style> | |
<body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3-geo-projection/0.2.9/d3.geo.projection.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.19/topojson.min.js"></script> | |
<script> | |
var width = 940, | |
height = 580; | |
var color_group = { | |
"Estonia": {"color":"#1b9e77", "same": ["Russian Federation"]}, | |
"Russian Federation": {"color":"#1b9e77", "same": ["Estonia"]}, | |
"Hungary": {"color":"#d95f02", "same": ["Slovakia", "Czech Republic", "Poland", "Slovenia", "Portugal", "Greece", "Spain", "Ireland", "Italy"]}, | |
"Slovakia": {"color":"#d95f02", "same": ["Hungary", "Czech Republic", "Poland", "Slovenia", "Portugal", "Greece", "Spain", "Ireland", "Italy"]}, | |
"Czech Republic": {"color":"#d95f02", "same": ["Hungary", "Slovakia", "Poland", "Slovenia", "Portugal", "Greece", "Spain", "Ireland", "Italy"]}, | |
"Poland": {"color":"#d95f02", "same": ["Hungary", "Slovakia", "Czech Republic", "Slovenia", "Portugal", "Greece", "Spain", "Ireland", "Italy"]}, | |
"Slovenia": {"color":"#d95f02", "same": ["Hungary", "Slovakia", "Czech Republic", "Poland", "Portugal", "Greece", "Spain", "Ireland", "Italy"]}, | |
"Portugal": {"color":"#d95f02", "same": ["Hungary", "Slovakia", "Czech Republic", "Poland", "Slovenia", "Greece", "Spain", "Ireland", "Italy"]}, | |
"Greece": {"color":"#d95f02", "same": ["Hungary", "Slovakia", "Czech Republic", "Poland", "Slovenia", "Portugal", "Spain", "Ireland", "Italy"]}, | |
"Spain": {"color":"#d95f02", "same": ["Hungary", "Slovakia", "Czech Republic", "Poland", "Slovenia", "Portugal", "Greece", "Ireland", "Italy"]}, | |
"Ireland": {"color":"#d95f02", "same": ["Hungary", "Slovakia", "Czech Republic", "Poland", "Slovenia", "Portugal", "Greece", "Spain", "Italy"]}, | |
"Italy": {"color":"#d95f02", "same": ["Hungary", "Slovakia", "Czech Republic", "Poland", "Slovenia", "Portugal", "Greece", "Spain", "Ireland"]}, | |
"Canada": {"color":"#7570b3", "same": ["United States"]}, | |
"United States": {"color":"#7570b3", "same": ["Canada"]}, | |
"Australia": {"color":"#e7298a", "same": ["New Zealand", "Iceland", "United Kingdom", "Austria", "Germany", "Switzerland"]}, | |
"New Zealand": {"color":"#e7298a", "same": ["Australia", "Iceland", "United Kingdom", "Austria", "Germany", "Switzerland"]}, | |
"Iceland": {"color":"#e7298a", "same": ["Australia", "New Zealand", "United Kingdom", "Austria", "Germany", "Switzerland"]}, | |
"United Kingdom": {"color":"#e7298a", "same": ["Australia", "New Zealand", "Iceland", "Austria", "Germany", "Switzerland"]}, | |
"Austria": {"color":"#e7298a", "same": ["Australia", "New Zealand", "Iceland", "United Kingdom", "Germany", "Switzerland"]}, | |
"Germany": {"color":"#e7298a", "same": ["Australia", "New Zealand", "Iceland", "United Kingdom", "Austria", "Switzerland"]}, | |
"Switzerland": {"color":"#e7298a", "same": ["Australia", "New Zealand", "Iceland", "United Kingdom", "Austria", "Germany"]}, | |
"Belgium": {"color":"#66a61e", "same": ["France", "Netherlands", "Finland", "Norway", "Sweden", "Denmark", "Luxembourg"]}, | |
"France": {"color":"#66a61e", "same": ["Belgium", "Netherlands", "Finland", "Norway", "Sweden", "Denmark", "Luxembourg"]}, | |
"Netherlands": {"color":"#66a61e", "same": ["Belgium", "France", "Finland", "Norway", "Sweden", "Denmark", "Luxembourg"]}, | |
"Finland": {"color":"#66a61e", "same": ["Belgium", "France", "Netherlands", "Norway", "Sweden", "Denmark", "Luxembourg"]}, | |
"Norway": {"color":"#66a61e", "same": ["Belgium", "France", "Netherlands", "Finland", "Sweden", "Denmark", "Luxembourg"]}, | |
"Sweden": {"color":"#66a61e", "same": ["Belgium", "France", "Netherlands", "Finland", "Norway", "Denmark", "Luxembourg"]}, | |
"Denmark": {"color":"#66a61e", "same": ["Belgium", "France", "Netherlands", "Finland", "Norway", "Sweden", "Luxembourg"]}, | |
"Luxembourg": {"color":"#66a61e", "same": ["Belgium", "France", "Netherlands", "Finland", "Norway", "Sweden", "Denmark"]}, | |
"Mexico": {"color":"#e6ab02", "same":["Brazil", "Turkey", "Japan", "Republic of Korea", "Chile", "Israel"]}, | |
"Brazil": {"color":"#e6ab02", "same":["Mexico", "Turkey", "Japan", "Republic of Korea", "Chile", "Israel"]}, | |
"Turkey": {"color":"#e6ab02", "same":["Mexico", "Brazil", "Japan", "Republic of Korea", "Chile", "Israel"]}, | |
"Japan": {"color":"#e6ab02", "same":["Mexico", "Brazil", "Turkey", "Republic of Korea", "Chile", "Israel"]}, | |
"Republic of Korea": {"color":"#e6ab02", "same":["Mexico", "Brazil", "Turkey", "Japan", "Chile", "Israel"]}, | |
"Chile": {"color":"#e6ab02", "same":["Mexico", "Brazil", "Turkey", "Japan", "Republic of Korea", "Israel"]}, | |
"Israel": {"color":"#e6ab02", "same":["Mexico", "Brazil", "Turkey", "Japan", "Republic of Korea", "Chile"]} | |
} | |
var color = d3.scale.category10(); | |
var projection = d3.geo.mercator() | |
.scale(150) | |
.translate([width / 2, height / 2]) | |
.precision(.1); | |
var path = d3.geo.path() | |
.projection(projection); | |
var graticule = d3.geo.graticule(); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
svg.append("defs").append("path") | |
.datum({type: "Sphere"}) | |
.attr("id", "sphere") | |
.attr("d", path); | |
svg.append("use") | |
.attr("class", "stroke") | |
.attr("xlink:href", "#sphere"); | |
svg.append("use") | |
.attr("class", "fill") | |
.attr("xlink:href", "#sphere"); | |
svg.append("path") | |
.datum(graticule) | |
.attr("class", "graticule") | |
.attr("d", path) | |
.attr("display", "none"); | |
var tooltip = d3.select("body") | |
.append("div") | |
.style("position", "relative") | |
.style("z-index", "10") | |
.style("visibility", "hidden"); | |
d3.json("world.json", function(error, world) { | |
if (error) throw error; | |
var countries = topojson.feature(world, world.objects.subunits).features; | |
svg.selectAll(".country") | |
.data(countries) | |
.enter().insert("path", ".graticule") | |
.attr("class", "country") | |
.attr("d", path) | |
.attr("id", function(d) { | |
return "id_" + d.id | |
}) | |
.style("fill", function(d, i) { | |
if (d.id in color_group) { | |
return color_group[d.id]['color'] | |
} else { | |
return "rgba(20,20,20,.2)"} | |
}) | |
.on("mouseover", function(d,i){ | |
tooltip.style("visibility", "visible"); | |
same_group_list = color_group[d.id]["same"] | |
same_group_text = "" | |
for (country in color_group[d.id]["same"]) { | |
country_name = color_group[d.id]["same"][country] | |
if (country == same_group_list.length - 1) { | |
same_group_text = same_group_text + country_name + " in terms of Better Life Index (2015)." | |
} else { | |
same_group_text = same_group_text+ country_name + ", " | |
} | |
} | |
tooltip.html("<span><strong>"+d.id+"</strong> is in the same group as " + same_group_text +"</span>") | |
}) | |
.on("mouseout", function(d,i){ | |
tooltip.html(null); | |
}); | |
svg.insert("path", ".graticule") | |
.datum(topojson.mesh(world, world.objects.subunits, function(a, b) { return a !== b; })) | |
.attr("class", "boundary") | |
.attr("d", path); | |
}); | |
d3.select(self.frameElement).style("height", height + "px"); | |
</script> |
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
0 info it worked if it ends with ok | |
1 verbose cli [ 'node', '/usr/local/bin/npm', 'install' ] | |
2 info using [email protected] | |
3 info using [email protected] | |
4 verbose readDependencies loading dependencies from /Users/Jun/Desktop/blocks/mercatomap/package.json | |
5 error install Couldn't read dependencies | |
6 verbose stack Error: ENOENT, open '/Users/Jun/Desktop/blocks/mercatomap/package.json' | |
6 verbose stack at Error (native) | |
7 verbose cwd /Users/Jun/Desktop/blocks/mercatomap | |
8 error Darwin 14.4.0 | |
9 error argv "node" "/usr/local/bin/npm" "install" | |
10 error node v0.12.7 | |
11 error npm v2.11.3 | |
12 error path /Users/Jun/Desktop/blocks/mercatomap/package.json | |
13 error code ENOPACKAGEJSON | |
14 error errno -2 | |
15 error package.json ENOENT, open '/Users/Jun/Desktop/blocks/mercatomap/package.json' | |
15 error package.json This is most likely not a problem with npm itself. | |
15 error package.json npm can't find a package.json file in your current directory. | |
16 verbose exit [ -2, true ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment