Skip to content

Instantly share code, notes, and snippets.

View joshcarr's full-sized avatar
👁️
Seeing

Josh Carr joshcarr

👁️
Seeing
View GitHub Profile
// XL for Bootstrap 3
// Huge screen / massive desktop
// Inspired from: https://github.com/christhomas/bootstrap/commit/09c94ab34a497785f3112a5951f225c21aec6aaa
// Note: whoever didn't think of this in bootstrap needs slapping
@screen-xl: 1600px;
@screen-xl-min: @screen-xl;
@screen-xl-desktop: @screen-xl-min;
@screen-lg-max: (@screen-xl-min - 1);

After the Irish Famine

This is a simple visualization of population change in Ireland during the [Great Famine][] era. It uses continuous area cartograms and population estimates from 1841 to 2001 to demonstrate change. The cool thing about this visualization is how dramatically it emphasizes population loss from 1841 to 1851 (and beyond), and how, even in modern Ireland, many counties remain well below their pre-famine population levels. As a whole, the population of Ireland remains less than 70% of its pre-famine levels!

A popover gives you additional information on mouse over. This includes county name, total population for the give year, and a nice little [sparkline][] showing population change over time (with the current year highlighted for reference). This gives a nice quick feel for the population change over time, and was pretty easy to do using D3js and Twitter Bootstrap.

This visualization uses [D3js][], [colorbrewer][], Twitter's [Bootstrap][], [jQuery][], and some helpful examples from [here

Fine-grained control of randomly entering and exiting things in D3.js, for impeccable object constancy. Adapted from an example co-authored with Mike Bostock.

Computing hexbins from a constantly-fluctuating sample of 2,000 random points.

[
[103,104,104,105,105,106,106,106,107,107,106,106,105,105,104,104,104,104,105,107,107,106,105,105,107,108,109,110,110,110,110,110,110,109,109,109,109,109,109,108,107,107,107,107,106,106,105,104,104,104,104,104,104,104,103,103,103,103,102,102,101,101,100,100,100,100,100,99,98,97,97,96,96,96,96,96,96,96,95,95,95,94,94,94,94,94,94],
[104,104,105,105,106,106,107,107,107,107,107,107,107,106,106,106,106,106,106,108,108,108,106,106,108,109,110,110,112,112,113,112,111,110,110,110,110,109,109,109,108,107,107,107,107,106,106,105,104,104,104,104,104,104,104,103,103,103,103,102,102,101,101,100,100,100,100,99,99,98,97,97,96,96,96,96,96,96,96,95,95,95,94,94,94,94,94],
[104,105,105,106,106,107,107,108,108,108,108,108,108,108,108,108,108,108,108,108,110,110,110,110,110,110,110,111,113,115,116,115,113,112,110,110,110,110,110,110,109,108,108,108,108,107,106,105,105,105,105,105,105,104,104,104,104,103,103,103,102,102,102,101,100,100,100,99,99,98,97,97,96,96,96,96,96,96,96,96,95,95,94,94,94,94,94],
[105,105,106,106,107,107,108,
@joshcarr
joshcarr / README.md
Last active August 29, 2015 14:04
d3.js scatterplot and heat (density) chart

d3.js example showing a scatterplot with 500-50,000 random points and its associated density heat chart

@joshcarr
joshcarr / index.html
Last active August 29, 2015 14:04
Scatterplot
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
</head>
<body>
<script>
function getRandomArbitrary(min, max) {
@joshcarr
joshcarr / README.md
Last active August 29, 2015 14:04 — forked from mbostock/.block

This brush snaps to day boundaries. When the user releases the brush, the brush fires a brushend event, allowing a listener to adjust the brush extent. Using the new brush transitions released in D3 3.3, the brush smoothly interpolates from the original extent to the rounded extent. Compare this approach to using immediate snapping while brushing.

@joshcarr
joshcarr / defaults.js
Created July 23, 2014 17:23
Set a default parameter value for a JavaScript function
// http://stackoverflow.com/questions/894860/set-a-default-parameter-value-for-a-javascript-function
// There are a lot of ways, but this is my preferred method
// it lets you pass in anything you want, including false or null.
// (typeof null == "object")
function foo(a, b){
a = typeof a !== 'undefined' ? a : 42;
b = typeof b !== 'undefined' ? b : 'default_b';
...
}
<!doctype html>
<meta charset="utf-8">
<html>
<head>
<style type="text/css">
#canvas {
width: 800px;
height: 400px;
border: 1px solid #666;
}