Skip to content

Instantly share code, notes, and snippets.

@patricksurry
patricksurry / README.md
Created February 5, 2018 16:28 — forked from tomgp/LICENSE.txt
Simple D3 clock

A simple clock made with D3.

After I'd made it I got a bit caught up in trying to make it look like Dieter Ram's Braun clock face adding a whole bunch fo extra stuff...

It's still not quite there.

@patricksurry
patricksurry / .block
Created February 5, 2018 15:04 — forked from mbostock/.block
Orthographic
license: gpl-3.0
@patricksurry
patricksurry / .block
Created May 31, 2017 17:26 — forked from mbostock/.block
Calendar View
license: gpl-3.0
height: 2910
border: no
@patricksurry
patricksurry / README.md
Last active December 20, 2017 12:02 — forked from mbostock/.block
Force layout with dynamic distance function

Click and drag to move states around. Move slider to modify distance function

Fork of mbostock's force layout example (http://bl.ocks.org/mbostock/1073373) with a few experimental changes.

Create links between neighbouring states (inferred from topojson mesh) rather than from Voronoi triangles which add some unstable cross-country links like Maine-Washington. Parameterize distance function with a slider (0 = spatial similarity only, 1 = more variation based on type similarity).

@patricksurry
patricksurry / README.md
Last active October 12, 2017 15:28 — forked from mbostock/.block
Rolling pan and zoom with Mercator projection

Example illustrating zoom and pan with a "rolling" Mercator projection. Drag left-right to rotate projection cylinder, and up-down to translate, clamped by max absolute latitude. Ensures projection always fits properly in viewbox.

@patricksurry
patricksurry / README.md
Last active June 17, 2023 09:48 — forked from mbostock/README.md
D3JS quadtree nearest neighbor algorithm

This example adapts mbostock's quadtree brushing demo to find the nearest neighbor (shown red) of a new point (shown yellow). Choose a new point to classify by clicking on the diagram. (An alternative approach for nearest neighbors of the mouse position is D3's Voronoi polygons, but the idea here would extend to rapidly classifying many new points against a base collection of points.)

We use a data-dependent order of recursion through the quadtree

@patricksurry
patricksurry / README.md
Last active March 28, 2023 23:31 — forked from dwtkns/README.md
Flying arcs with height proportional to length

Adapted from this, to avoid the second projection and make flying arc height proportional to length.

Because the 'sky' projection is just a scaled up version of the original one, the projection of a sky point in canvas coords can be easily calculated by scaling the ground projection point along the vector from the origin.

Another improvement(?) might be to avoid the swoosh/interpolate function by doing this same trick directly on the stream of points that comes from the normal projection path function.

@patricksurry
patricksurry / README.md
Last active February 15, 2017 13:49 — forked from mbostock/.block
D3 3D globe trackball rotation

This example illustrates a simple trackball approach for rotating an orthographic globe ' with D3 3.0.

The idea is to express a click on the sphere in spherical coordinates with one rotation axis horizontal on the page, and one axis vertical. Then when we move the mouse, we just rotate the underlying sphere so that the point of initial click stays underneath the mouse. When the globe is oriented in its original location (i.e. rotation(0,0), with the north pole at the top of the page and the equator aligned with the horizontal canvas axis, it's easy, since D3's longitude rotation equals trackball rotation around the vertical axis, and the subsequently applied latitude rotation