Demonstrates using d3.behavior.zoom
with a geographic projection. Based on an
example by Iain Dillingham.
D3 2.11’s projections will adaptively resample to reduce local distortion of lines. Move the mouse to change the precision, and drag to change the aspect.
Update: Mike has made some awesome improvements!
license: gpl-3.0 |
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!
build | |
node_modules |
A demo of Mike Bostock’s TopoJSON using states & provinces boundaries from Natural Earth.
With simplification turned on (-s 100
), this reduces the original 57MB GeoJSON file to a mere 515KB!
A demonstration of D3’s vertically-oriented bullet charts, based on this example.
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>Alpha-Shapes</title> | |
<script src="http://mbostock.github.com/d3/d3.min.js"></script> | |
<script src="http://mbostock.github.com/d3/d3.geom.min.js"></script> | |
<style type="text/css"> | |
path { |
A demonstration of how to calculate the areas of Voronoi regions clipped by geographic features using D3.
[D3’s implementation](Sutherland–Hodgman algorithm) of the Sutherland–Hodgman algorithm only works for convex clip polygons, but we exploit the fact that Voronoi regions are guaranteed to be convex, and use each Voronoi region as a clip polygon, with the projected geographic boundary as a subject polygon.
In response to a question by Gonzalo Bellver.
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Population Projection</title> | |
<link rel="stylesheet" href="main.css"> | |
</head> |