Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
💡

Jason Davies jasondavies

💭
💡
View GitHub Profile
@jasondavies
jasondavies / README.md
Last active August 29, 2015 14:04 — forked from mbostock/.block
Wrapped d3.geo.tile
View README.md
@jasondavies
jasondavies / README.md
Last active June 15, 2016 22:26 — forked from mbostock/.block
Rotated hexbin
View README.md

A version of Mike Bostock’s hexbin example, modified to use hexagons rotated by 90°. Aside from rotating the hexagon primitives, the only other change is to swap the meaning of x and y, for all inputs and outputs of the plugin.

@jasondavies
jasondavies / .gitignore
Last active August 29, 2015 14:04 — forked from mbostock/.block
Quantised States
View .gitignore
.DS_Store
build
node_modules
@jasondavies
jasondavies / README.md
Last active October 29, 2018 11:08 — forked from monsieurBelbo/caba.json
Areas of Clipped Voronoi Regions
View README.md

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.

@jasondavies
jasondavies / README.md
Last active August 29, 2015 13:58 — forked from mbostock/README.md
Voronoi Clip Bug
View README.md

There seems to be a bug in voronoi clipping; setting .clipExtent([[-1, -10], [width + 1, height + 1]]) works around the issue for these particular points.

@jasondavies
jasondavies / .gitignore
Last active October 27, 2019 19:48 — forked from mbostock/.block
Ocean
View .gitignore
build
node_modules
@jasondavies
jasondavies / README.md
Last active June 13, 2019 23:16 — forked from mbostock/.block
Vertical Bullet Charts
View README.md
@jasondavies
jasondavies / README.md
Created December 2, 2012 11:54 — forked from mbostock/.block
World Map
View README.md

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!

@jasondavies
jasondavies / README.md
Created December 2, 2012 10:04 — forked from jasondavies/README.md
AustraliaAustria
View README.md

Trying to figure out if there’s a problem with AustraliaAustria spherical linear interpolation in the [World Countries][1] example, as hinted at by Hadley Wickham.

Note how the geodesic is always a straight line under the orthographic projection, since it is always going through the centre. (Except for the initial view centred at (0°, 0°), which is not on the geodesic). This is true for all azimuthal projections.

@jasondavies
jasondavies / README.md
Created December 1, 2012 18:19 — forked from mbostock/.block
World Countries
View README.md