Possible schedule for a D3.JS workshop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/node | |
var vm = require('vm'); | |
var Writable = require('stream').Writable; | |
var ws = Writable(); | |
var chunks = []; | |
ws._write = function (chunk, enc, next) { | |
chunks.push(chunk); | |
next(); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<style> | |
body { | |
margin: 0; | |
} | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.js" charset="utf-8"></script> | |
<script> |
[ Launch: test ] 089a3d72e5fc01fd881f by vicapow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Checkout the project page at: https://github.com/shawnbot/masonic | |
(function(exports) { | |
var VERSION = "0.1.0"; | |
d3.masonic = function() { | |
var columnCount = 0, | |
columnWidth = 200, | |
outerWidth = 0, | |
outerHeight = 0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = [1, 2, [2], [1, 2, [3, 4, [5]]], [[4, 5], 3, 2, 1], [1]]; | |
function flatten(array) { | |
var stack = []; | |
var out = []; | |
var tail; | |
stack.push({array: array, idx: 0}); | |
while(stack.length) { | |
tail = stack[stack.length - 1]; | |
if (tail.idx >= tail.array.length) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var D3ReactTemplate = React.createClass({ | |
sel: function() { return d3.select(this.getDOMNode()) }, | |
getDefaultProps: function() { | |
return { | |
valueAccessor: function(d) { return d.value }, | |
width: 400, | |
height: 400 | |
} | |
}, | |
getInitialState: function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ordinary Least Squares | |
function ols(points_, pointAccessor) { | |
var points = points_.map(pointAccessor || function(d) { return d }) | |
var xmean = d3.mean(points, function(d) { return d[0] }) | |
var ymean = d3.mean(points, function(d) { return d[1] }) | |
var bNum = points | |
.reduce(function(c, d) { return (d[0] - xmean) * (d[1] - ymean) + c }, 0) | |
var bDenom = points | |
.reduce(function(c, d) { return c + Math.pow(d[0] - xmean, 2) }, 0) | |
var b = bNum / bDenom |
This demo uses d3.layout.force()
to calculate the node positions and then passes those to webGL to render them on the GPU.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from sklearn.decomposition import PCA | |
# X = np.array([ | |
# [ -2.500000000000001, -1.873333333333334], | |
# [ 0.2333333333333325, 0.026666666666666394], | |
# [ 0.8666666666666663, 0.8266666666666662], | |
# [ -1.7000000000000006, -1.1733333333333338], | |
# [ 3.1000000000000005, 2.1933333333333334] |