Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://d3js.org/d3.v5.min.js"></script>
</head>
@jameshenegan
jameshenegan / index.html
Created September 27, 2019 03:30
Updating Histogram
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://d3js.org/d3.v5.min.js"></script>
</head>
<body>
@jameshenegan
jameshenegan / binom.js
Created September 27, 2019 20:05
Sampling from a Binomial Distribution
class Binom {
constructor(n, p) {
this.n = n,
this.p = p
this.pmf = this.makePMF()
this.cdf = this.makeCDF()
}
binomialSumArg(n, i, p) {
return choose(n, i) * Math.pow(p, i) * Math.pow(1 - p, n - i)
@jameshenegan
jameshenegan / index.html
Last active September 28, 2019 16:09
Approximating a Square Wave
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Fourier Approximation</title>
<script src="https://d3js.org/d3.v5.min.js"></script>
</head>
<body>
@jameshenegan
jameshenegan / canvas.js
Last active September 29, 2019 16:50
Mandelbrot D3.js V5
var margin = { top: 10, right: 30, bottom: 30, left: 60 },
width = 400 - margin.left - margin.right,
height = 400 - margin.top - margin.bottom;
const epochs = 150
const pointsPerEpoch = 2000
var data
var xMin = -1.5, xMax = 0.6, yMin = -1.05, yMax = 1.05
const xLength = xMax - xMin
const yLength = yMax - yMax
@jameshenegan
jameshenegan / index.html
Last active September 30, 2019 03:11
Transitions with Variable Durations
<!DOCTYPE html>
<head>
<script src="https://d3js.org/d3.v5.min.js"></script>
</head>
<body>
<div id = "chart"></div>
<button type="button" style = "position: absolute; left: 550px">Click to Restart</button>
<script src="index.js"></script>
@jameshenegan
jameshenegan / index.html
Last active September 30, 2019 22:52
D3.V5 Sequential Multi Hue Color Scale
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://d3js.org/d3.v5.min.js"></script>
</head>
@jameshenegan
jameshenegan / index.html
Last active October 12, 2019 18:56
VC Dimension, Axis Aligned Rectanges
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://d3js.org/d3.v5.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
@jameshenegan
jameshenegan / index.html
Last active June 21, 2020 13:47
Complete Graph Manipulation Viz
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://d3js.org/d3.v5.min.js"></script>
</head>
@jameshenegan
jameshenegan / index.html
Last active June 21, 2020 13:44
Latin Squares
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://d3js.org/d3.v5.min.js"></script>
</head>