Skip to content

Instantly share code, notes, and snippets.

@syntagmatic
syntagmatic / index.html
Created Mar 9, 2012
Albers to Azimuthal
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Projection Demo</title>
<script type='text/javascript' src='http://mbostock.github.com/d3/d3.v2.js'></script>
<style type='text/css'>
body {
margin:5px auto;
}
h1 {
@syntagmatic
syntagmatic / scroller.js
Last active Sep 26, 2016
Scroller - Add a button to scroll smoothly down a page
View scroller.js
// run in a javascript console to add an auto-scroller to the page
var scroller = (function() {
var button = document.createElement('button'),
scroller = {},
scrollerY = 0,
going = false,
last = 0,
requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
@syntagmatic
syntagmatic / demo.css
Created Mar 15, 2012 — forked from RichMorin/demo.css
Selectable Projection Demo
View demo.css
/* demo.css */
body {
margin: 5px auto;
}
#chart svg {
border: solid 1px #ccc;
}
View coffee-script.js
/**
* CoffeeScript Compiler v1.2.0
* http://coffeescript.org
*
* Copyright 2011, Jeremy Ashkenas
* Released under the MIT License
*/
(function(root){var CoffeeScript=function(){function require(a){return require[a]}require["./helpers"]=new function(){var a=this;(function(){var b,c;a.starts=function(a,b,c){return b===a.substr(c,b.length)},a.ends=function(a,b,c){var d;d=b.length;return b===a.substr(a.length-d-(c||0),d)},a.compact=function(a){var b,c,d,e;e=[];for(c=0,d=a.length;c<d;c++)b=a[c],b&&e.push(b);return e},a.count=function(a,b){var c,d;c=d=0;if(!b.length)return 1/0;while(d=1+a.indexOf(b,d))c++;return c},a.merge=function(a,c){return b(b({},a),c)},b=a.extend=function(a,b){var c,d;for(c in b)d=b[c],a[c]=d;return a},a.flatten=c=function(a){var b,d,e,f;d=[];for(e=0,f=a.length;e<f;e++)b=a[e],b instanceof Array?d=d.concat(c(b)):d.push(b);return d},a.del=function(a,b){var c;c=a[b],delete a[b];return c},a.last=function(a,b){return a[a.length-(b||0)-1]}}).call(this)},require["./rewriter"]=new function(){var
@syntagmatic
syntagmatic / coffee-script.js
Created Mar 17, 2012 — forked from RichMorin/coffee-script.js
Hive Plot Cardinal Interpolation Tensions
View coffee-script.js
/**
* CoffeeScript Compiler v1.2.0
* http://coffeescript.org
*
* Copyright 2011, Jeremy Ashkenas
* Released under the MIT License
*/
(function(root){var CoffeeScript=function(){function require(a){return require[a]}require["./helpers"]=new function(){var a=this;(function(){var b,c;a.starts=function(a,b,c){return b===a.substr(c,b.length)},a.ends=function(a,b,c){var d;d=b.length;return b===a.substr(a.length-d-(c||0),d)},a.compact=function(a){var b,c,d,e;e=[];for(c=0,d=a.length;c<d;c++)b=a[c],b&&e.push(b);return e},a.count=function(a,b){var c,d;c=d=0;if(!b.length)return 1/0;while(d=1+a.indexOf(b,d))c++;return c},a.merge=function(a,c){return b(b({},a),c)},b=a.extend=function(a,b){var c,d;for(c in b)d=b[c],a[c]=d;return a},a.flatten=c=function(a){var b,d,e,f;d=[];for(e=0,f=a.length;e<f;e++)b=a[e],b instanceof Array?d=d.concat(c(b)):d.push(b);return d},a.del=function(a,b){var c;c=a[b],delete a[b];return c},a.last=function(a,b){return a[a.length-(b||0)-1]}}).call(this)},require["./rewriter"]=new function(){var
View Heatmap
var defaults = {
dotsize: 5,
gutsize: 1,
totsize: 6
}
function heatmap(id, data, options) {
var self = {};
var options = _.extend(defaults, options);
self.data = data || [];
@syntagmatic
syntagmatic / gist:2202660
Created Mar 26, 2012
Export CSV with Javascript
View gist:2202660
// assumes variable data, which is a homogenous collection of objects
// get keys
var keys = _.keys(data[0]);
// convert to csv string
var csv = keys.join(",");
_(data).each(function(row) {
csv += "\n";
csv += _(keys).map(function(k) {
@syntagmatic
syntagmatic / data.csv
Created Mar 28, 2012
Simple bars with hover event
View data.csv
item num change
Basetables 44 2
Fields 941 159
File Access 2 1
File References 0
Base Directories 0
Tables 73 -93
Relationships 208 60
Value Lists 47 21
@syntagmatic
syntagmatic / force.js
Created Apr 4, 2012
Nutrient Scatterplot
View force.js
// adapted from http://bl.ocks.org/1747543
function force_layout() {
var width = 500,
height = 400,
padding = 3;
var circle = svg.selectAll("circle");
var nodes = circle
.each(function(d) {
@syntagmatic
syntagmatic / README.md
Created Apr 5, 2012 — forked from jasondavies/.block
Parallel Coordinates Coloring
View README.md

Adapted from a parallel coordinates example to demonstrate coloring based on the name column in the CSV. Cars which contain the string "Buick" are colored red.