Skip to content

Instantly share code, notes, and snippets.

@mpmckenna8
mpmckenna8 / README.md
Last active August 29, 2015 13:58 — forked from mbostock/.block

Based on Mike Bostock’s [World Map][0], modified to automatically colour countries such that no adjacent countries share the same colour.

This is done by extracting the topology via [TopoJSON][1] and greedily picking colours until the constraint is fulfilled.

See also: [Graph coloring][2] on Wikipedia.

Update: Greedily colouring is now performed in a single line, thanks to Mike Bostock!

@mpmckenna8
mpmckenna8 / README.md
Last active August 29, 2015 13:59 — forked from lobodin/README.md
Geonames cities to mongoDB thing

#Generate cities data

  1. wget http://download.geonames.org/export/dump/cities15000.zip
  2. unzip cities15000.zip
  3. node geonames.js cities15000.txt

The result is json array of cities in the following format:

{

_id:

.DS_Store
node_modules
us-judicial-districts.zip
build

Based on Mike Bostock’s [World Map][0], modified to automatically colour countries such that no adjacent countries share the same colour.

This is done by extracting the topology via [TopoJSON][1] and greedily picking colours until the constraint is fulfilled.

See also: [Graph coloring][2] on Wikipedia.

Update: Greedily colouring is now performed in a single line, thanks to Mike Bostock!

<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
var width = 960,
height = 500;
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.6.0"></script>
</head>
<body>
<svg>
<defs>
<mask id="rekt">
<g id="rrr">