Skip to content

Instantly share code, notes, and snippets.

@diggetybo
diggetybo / d3tip.js
Created December 5, 2017 07:34
Inner Boundary Example
// d3.tip
// Copyright (c) 2013 Justin Palmer
//
// Tooltips for d3.js SVG visualizations
// Public - contructs a new tooltip
//
// Returns a tip
d3.tip = function() {
var direction = d3_tip_direction,
@diggetybo
diggetybo / index.html
Created November 25, 2017 08:54
US Map
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="https://d3js.org/d3.v3.min.js"></script>
<style type="text/css">
/* On mouse hover, lighten state color */
path:hover {
@diggetybo
diggetybo / index.html
Last active November 8, 2017 01:18
Hourly Data Line Chart
<!DOCTYPE html>
<meta charset="utf-8">
<style>
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var margins = { top: 10, left: 20, right: 0, bottom: 0, between: 50 };
var width = 300, height = 100;
@diggetybo
diggetybo / cloud.js
Last active June 26, 2017 09:21
Minimalist Word Cloud
// Word cloud layout by Jason Davies, http://www.jasondavies.com/word-cloud/
// Algorithm due to Jonathan Feinberg, http://static.mrfeinberg.com/bv_ch03.pdf
(function() {
function cloud() {
var size = [256, 256],
text = cloudText,
font = cloudFont,
fontSize = cloudFontSize,
fontStyle = cloudFontNormal,
fontWeight = cloudFontNormal,
@diggetybo
diggetybo / dt.csv
Last active May 16, 2017 06:53
Decision Tree Plot
x1 x2 y1 y2 id
0.000000000000000000e+00 7.000000000000000000e+00 0.000000000000000000e+00 8.000000119209289551e-01 0
0.000000000000000000e+00 4.949999809265136719e+00 8.000000119209289551e-01 1.650000095367431641e+00 1
0.000000000000000000e+00 4.949999809265136719e+00 1.650000095367431641e+00 1.750000000000000000e+00 2
4.949999809265136719e+00 7.000000000000000000e+00 8.000000119209289551e-01 1.549999952316284180e+00 2
4.949999809265136719e+00 5.449999809265136719e+00 1.549999952316284180e+00 1.750000000000000000e+00 1
5.449999809265136719e+00 7.000000000000000000e+00 1.549999952316284180e+00 1.750000000000000000e+00 2
0.000000000000000000e+00 4.850000381469726562e+00 1.750000000000000000e+00 3.000000000000000000e+00 2
4.850000381469726562e+00 7.000000000000000000e+00 1.750000000000000000e+00 3.000000000000000000e+00 2
@diggetybo
diggetybo / index.html
Last active April 18, 2017 04:58
Mix and Match System
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<head>
<style>
text {
font-family: Play;
}
form .s1 {
@diggetybo
diggetybo / index.html
Last active March 28, 2017 09:03
JSON County in State Event
<html><head><meta charset="utf-8">
<title>County in State</title>
<style>
</style>
</head><body>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
@diggetybo
diggetybo / index.html
Created March 26, 2017 14:04
Geo Circles
<html><head><meta charset="utf-8">
<title>Geo Circle</title>
<style>
.button {
font-family: Play;
color: #ffffff;
font-size: 16px;
text-align: center;
display: inline-block;
-webkit-user-select: none;
@diggetybo
diggetybo / d3-polygon.v1.min.js
Created March 20, 2017 17:02
User Input Coordinate
// https://d3js.org/d3-polygon/ Version 1.0.2. Copyright 2016 Mike Bostock.
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.d3=n.d3||{})}(this,function(n){"use strict";function r(n,r){return n[0]-r[0]||n[1]-r[1]}function e(n){for(var r=n.length,e=[0,1],t=2,o=2;o<r;++o){for(;t>1&&f(n[e[t-2]],n[e[t-1]],n[o])<=0;)--t;e[t++]=o}return e.slice(0,t)}var t=function(n){for(var r,e=-1,t=n.length,o=n[t-1],f=0;++e<t;)r=o,o=n[e],f+=r[1]*o[0]-r[0]*o[1];return f/2},o=function(n){for(var r,e,t=-1,o=n.length,f=0,u=0,l=n[o-1],i=0;++t<o;)r=l,l=n[t],i+=e=r[0]*l[1]-l[0]*r[1],f+=(r[0]+l[0])*e,u+=(r[1]+l[1])*e;return i*=3,[f/i,u/i]},f=function(n,r,e){return(r[0]-n[0])*(e[1]-n[1])-(r[1]-n[1])*(e[0]-n[0])},u=function(n){if((o=n.length)<3)return null;var t,o,f=new Array(o),u=new Array(o);for(t=0;t<o;++t)f[t]=[+n[t][0],+n[t][1],t];for(f.sort(r),t=0;t<o;++t)u[t]=[f[t][0],-f[t][1]];var l=e(f),i=e(u),g=i[0]===l[0],a=i[i.length-1]===l[l.length-1]
@diggetybo
diggetybo / index.html
Last active March 7, 2017 10:42
Save Visual as File
<!DOCTYPE html>
<html>
<head>
<title>Coefficient Analysis</title>
<style type="text/css">
</style>
<meta charset="utf-8">
</head>
<script src="https://d3js.org/d3.v3.min.js"></script>