Skip to content

Instantly share code, notes, and snippets.

View mwdchang's full-sized avatar

Daniel Chang mwdchang

View GitHub Profile
@mwdchang
mwdchang / README.md
Created December 20, 2014 04:49
Slight variation on bostock's clipping venn

Add outline and interactions to bostock's clipping venn

package fun;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import java.nio.ByteBuffer;
import java.util.GregorianCalendar;
import java.util.Locale;
@mwdchang
mwdchang / index.html
Last active August 29, 2015 14:17
Demo for Aly
<!DOCTYPE HTML>
<html>
<head>
<title> Drag/Link Test </title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"></script>
<style>
body {
margin: 1em;
@mwdchang
mwdchang / index.html
Created June 19, 2015 13:47
Demoing the lens technique. The lens is used to focus, and reveal another dimension on the dataset.
<html>
<head>
<!--
<script src="d3.js" charset="utf-8"></script>
<script src="lodash.js"></script>
-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.9.3/lodash.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script>
<style>
@mwdchang
mwdchang / index.html
Created March 24, 2016 20:53
Zoomable Calendar
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.12/d3.js"></script>
<style>
body {
font-family: Tahoma;
font-size: 0.7rem;
}
@mwdchang
mwdchang / index.html
Last active August 12, 2016 02:59
Grid Test
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js"></script>
<script src="stckr.js"></script>
<link rel="stylesheet" href="stckr.css">
<style>
body {
margin: 1rem;
font-family: Tahoma;
}
@mwdchang
mwdchang / index.html
Created July 12, 2016 19:08
FF and Chrome absolute element event positions
<!DOCTYPE HTML>
<html>
<head>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.js"></script>
<style>
#d1 {
width: 600px;
height: 600px;
background: #CCC;
@mwdchang
mwdchang / index.html
Created July 13, 2016 14:28
D3 zoom behaviour offset
<!DOCTYPE HTML>
<html>
<head>
<script src="https://d3js.org/d3.v3.min.js"></script>
<style>
#div1 {
width: 500px;
height: 500px;
background: #CCC;
}
@mwdchang
mwdchang / index.html
Last active July 13, 2016 15:06
D3 v4 odd zoom behaviour
<!DOCTYPE HTML>
<html>
<head>
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
#div1 {
width: 500px;
height: 500px;
background: #CCC;
}
@mwdchang
mwdchang / PCC.js
Last active November 1, 2016 02:05
Pearson correlation coefficient function
// Based on: https://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient
static PCC(x, y) {
let n = x.length;
let sum_xy = 0;
let sum_x2 = 0;
let sum_y2 = 0;
let meanx = 0, meany = 0;
for (let i=0; i < n; i++) {
sum_xy += x[i]*y[i];
sum_x2 += x[i]*x[i];