Skip to content

Instantly share code, notes, and snippets.

@nsonnad
nsonnad / parentData.js
Created March 12, 2013 03:58
D3: access parent data
(function(d, i, j){
console.log('Method A: Parent data: ', data[j], 'Parent index: ', j);
console.log('Method B: Parent data: ', this.parentNode.__data__);
return d;
});
@nsonnad
nsonnad / _.md
Created March 14, 2013 02:16
.attr() after .each()
@nsonnad
nsonnad / _.md
Last active December 17, 2015 13:29
simple crossfilter, Melb water use
# Editor backup files
*.bak
*~
@nsonnad
nsonnad / _.md
Created June 13, 2013 12:00
d3.sticker
@nsonnad
nsonnad / _.md
Created June 20, 2013 11:40
Tributary inlet
@nsonnad
nsonnad / index.html
Last active May 26, 2016 01:03
Playing around with d3's transition easing options.
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>d3.transition.ease()</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h2>d3.transition().ease("<span id="easeId"></span>")</h2>
@nsonnad
nsonnad / index.js
Created July 2, 2013 07:35
Multi-foci d3 force layout, based on data
force.on("tick", function(e) {
// Push nodes toward their designated focus.
var k = .1 * e.alpha;
nodes.forEach(function(o, i) {
o.y += (foci[o.id].y - o.y) * k;
o.x += (foci[o.id].x - o.x) * k;
});
vis.selectAll("circle.node")