Skip to content

Instantly share code, notes, and snippets.

@DavidChouinard
DavidChouinard / .block
Last active July 27, 2016 21:26 — forked from mbostock/.block
Modifying a Force Layout on D3 v4
license: gpl-3.0
@DavidChouinard
DavidChouinard / README.md
Last active August 29, 2015 14:15 — forked from mbostock/.block
Multi-Foci Force Layout

Click to perturb or drag the nodes!

This example demonstrates the flexibility of D3's force layout. By using position Verlet integration, it is easy to add custom forces to a layout. In this example, the nodes are clustered around four foci using additional forces: the odd nodes are pushed down, the even nodes are pushed up, and a similar bisecting force is applied laterally. These custom forces are based purely on the index of the node, but they could just as easily be derived from properties of data!

Based on this, edited for clarity

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

This donut chart is constructed from a CSV file storing the populations of various age groups. The chart employs a number of D3 features:

@DavidChouinard
DavidChouinard / demo.js
Last active October 19, 2015 18:45
Act V: Mapping
// You'll generally need a local server for requests to work. Run:
// python -m SimpleHTTPServer
var width = 700,
height = 500;
var svg = d3.select("svg")
.attr("width", width)
.attr("height", height);
@DavidChouinard
DavidChouinard / data.json
Created November 12, 2014 15:41
Act IV: Working with Data
[
{"magnitude":5.1,"coordinates":[-71.120167,42.370580]},
{"magnitude":2.73,"coordinates":[-119.6165,41.9069]},
{"magnitude":3.35,"coordinates":[-124.9986649,40.409668]},
{"magnitude":4.1,"coordinates":[-97.0925,36.0305]},
{"magnitude":3.4,"coordinates":[-152.9566,59.0462]}
]
@DavidChouinard
DavidChouinard / demo.js
Created November 12, 2014 15:40
Act III: Scales
// You'll generally need a local server for requests to work. Run:
// python -m SimpleHTTPServer
var width = 700,
height = 500;
var svg = d3.select("svg")
.attr("width", width)
.attr("height", height);
@DavidChouinard
DavidChouinard / demo.js
Created November 12, 2014 15:32
Act II: Data-driven documents
// You'll generally need a local server for requests to work. Run:
// python -m SimpleHTTPServer
var width = 700,
height = 500;
var svg = d3.select("svg")
.attr("width", width)
.attr("height", height);
@DavidChouinard
DavidChouinard / demo.js
Last active August 29, 2015 14:09
Act I: DOM Manipulation
// You'll generally need a local server for requests to work. Run:
// python -m SimpleHTTPServer
var width = 700,
height = 500;
var svg = d3.select("svg")
.attr("width", width)
.attr("height", height);

Keybase proof

I hereby claim:

  • I am DavidChouinard on github.
  • I am davidchouinard (https://keybase.io/davidchouinard) on keybase.
  • I have a public key whose fingerprint is F38B 4647 11C1 89A7 184A 2D21 9E67 28F1 2084 DF2A

To claim this, I am signing this object: