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 10, 2013 05:14
basic data re-join in d3
@nsonnad
nsonnad / D3: Select all but this
Created March 5, 2013 08:28
select all but this in d3
function mouseOn () {
var circleUnderMouse = this;
d3.selectAll('.rectGroup').transition().style('opacity',function () {
return (this === circleUnderMouse) ? 1.0 : 0.5;
});
}
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>blah</title>
</head>
<body>
</body>
</html>
@nsonnad
nsonnad / index.html
Last active December 11, 2015 20:18
Legislative Yuan similarity
<!DOCTYPE html>
<html>
<head>
<script src="https://raw.github.com/mbostock/d3/master/d3.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="https://raw.github.com/betamos/Better-Autocomplete/develop/src/jquery.better-autocomplete.js"></script>
<style type="text/css">
.link {
stroke: #999;
@nsonnad
nsonnad / index.html
Created January 16, 2013 05:54
Area + donut: History of energy use in the US
<!DOCTYPE html>
<html>
<head>
<title>US Historical Energy Consumption</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<!--<script src="http://code.jquery.com/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.tipsy.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="http://onehackoranother.com/projects/jquery/tipsy/stylesheets/tipsy.css" type="text/css" title="no title" charset="utf-8"/> -->
<style type="text/css">
@nsonnad
nsonnad / _.md
Last active December 11, 2015 02:08
Axis grid using groups
@nsonnad
nsonnad / _.md
Last active December 11, 2015 02:08
D3 axis grid lines
@nsonnad
nsonnad / index.html
Created January 10, 2013 04:01 — forked from ejfox/index.html
<!doctype html>
<html>
<head>
<title></title>
<meta charset=utf-8>
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript" src="https://raw.github.com/square/crossfilter/master/crossfilter.min.js"></script>
<style>
body {
font-size: 100%;
@nsonnad
nsonnad / README.md
Last active December 10, 2015 19:29
Scatterplot: Social trust vs ease of doing business

A scatterplot using d3js. It maps social trust against ease of doing business in various countries. For tooltips, it makes use of Justin Donaldson's fork of the jQuery plugin tipsy. Data come from the Pew Global Attitudes project and the Doing Business rankings. For a live example see my post on it or http://bl.ocks.org/4481531