Skip to content

Instantly share code, notes, and snippets.

@nsonnad
nsonnad / index.js
Created October 4, 2013 15:11
Gist from mistakes.io
categories = ["funny", "stupid", "sad", "embarassing"];
tabData = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]];
mapped = categories.map(function(cat) {
return tabData.map(function(d) {
return {
name: cat, value: d[categories.indexOf(cat)]
};
});
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nsonnad
nsonnad / index.html
Created September 19, 2013 10:51
invisible element to load web font before getBBox needs it
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Text bbox issue</title>
</head>
<style type="text/css" media="screen">
@import url(http://fonts.googleapis.com/css?family=Cutive);
svg text {
@nsonnad
nsonnad / _.md
Created July 25, 2013 22:57
optical_illusion_001_motion2
@nsonnad
nsonnad / README.md
Last active December 19, 2015 16:19 — forked from mbostock/.block
Colored links in force-directed graph

Simple change to Mike Bostock's force-directed graph, adding colors to links.

This simple force-directed graph shows character co-occurence in Les Misérables. A physical simulation of charged particles and springs places related characters in closer proximity, while unrelated characters are farther apart. Layout algorithm inspired by Tim Dwyer and Thomas Jakobsen. Data based on character coappearence in Victor Hugo's Les Misérables, compiled by Donald Knuth.

@nsonnad
nsonnad / _.md
Created July 7, 2013 04:03
psi man
<!DOCTYPE html>
<html>
<head>
<title>Force-Directed Layout (Multiple Foci)</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js"></script>
</head>
<body>
<script type="text/javascript">
@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")
@nsonnad
nsonnad / _.md
Created June 20, 2013 11:40
Tributary inlet