Skip to content

Instantly share code, notes, and snippets.

@dukevis
dukevis / d3.min.js
Last active September 19, 2015 01:31 — forked from asifr/data.json
Punchcard visualization using D3.js
!function(){function n(n){return n&&(n.ownerDocument||n.document||n).documentElement}function t(n){return n&&(n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView)}function e(n,t){return t>n?-1:n>t?1:n>=t?0:0/0}function r(n){return null===n?0/0:+n}function u(n){return!isNaN(n)}function i(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function o(n){return n.length}function a(n){for(var t=1;n*t%1;)t*=10;return t}function c(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function l(){this._=Object.create(null)}function s(n){return(n+="")===pa||n[0]===va?va+n:n}function f(n){return(n+="")[0]===va?n.slice(1):n}function h(n){return s(n)in this._}function g(n){return(n=s(n))in this._&&delete this._[n]}function p(){var n=[]
@dukevis
dukevis / colorbrewer.js
Created September 14, 2015 02:36
sexual disorder streamgraph
// This product includes color specifications and designs developed by Cynthia Brewer (http://colorbrewer.org/).
var colorbrewer = {YlGn: {
3: ["#f7fcb9","#addd8e","#31a354"],
4: ["#ffffcc","#c2e699","#78c679","#238443"],
5: ["#ffffcc","#c2e699","#78c679","#31a354","#006837"],
6: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#31a354","#006837"],
7: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
8: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
9: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"]
},YlGnBu: {
@dukevis
dukevis / colorbrewer.js
Created September 14, 2015 02:33
autism streamgraph
// This product includes color specifications and designs developed by Cynthia Brewer (http://colorbrewer.org/).
var colorbrewer = {YlGn: {
3: ["#f7fcb9","#addd8e","#31a354"],
4: ["#ffffcc","#c2e699","#78c679","#238443"],
5: ["#ffffcc","#c2e699","#78c679","#31a354","#006837"],
6: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#31a354","#006837"],
7: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
8: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
9: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"]
},YlGnBu: {
@dukevis
dukevis / index.html
Created September 14, 2015 02:30
mental disabilities streamgraph
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="nv.d3.css" rel="stylesheet" type="text/css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.2/d3.min.js" charset="utf-8"></script>
<script src="nv.d3.js"></script>
<style>
text {
@dukevis
dukevis / mental_flot_data.csv
Created September 13, 2015 15:37
recline_test
year intellectual disability learning disability mental deficiency mental handicap mental retardation other mental term
1945 0.017857143 0.089285714 0.017857143
1946 0.085561497 0.010695187 0.021390374
1947 0.004975124 0.064676617 0.004975124 0.009950249
1948 0.071770335 0.014354067 0.004784689
1949 0.058365759 0.003891051 0.019455253 0.011673152
1950 0.033846154 0.006153846 0.012307692 0.006153846
1951 0.001179245 0.047169811 0.001179245 0.018867925 0.004716981
1952 0.025879917 0.004140787 0.025879917 0.007246377
1953 0.001046025 0.001046025 0.040794979 0.005230126 0.018828452 0.003138075
@dukevis
dukevis / Readme.md
Last active September 11, 2015 18:43 — forked from WillTurman/Readme.md
D3 Interactive Streamgraph

D3 Streamgraph Example

Series Hover

The series hover interactivity uses the technique from lgrammel seen here: http://bl.ocks.org/1963983

Data Tooltip

It isn't necessarily a tooltip, but data is displayed by inverting the x-axis value into a date, and mapping the date to the corresponding data value for the series.

@dukevis
dukevis / basketball_data.csv
Last active August 29, 2015 14:00
chord diagram + multiline chart
Year UNC Duke NCS WF MD UVA Clem
1954 0 1 3 2 1 0 0
1955 0 3 6 3 1 1 0
1956 1 4 9 5 1 1 0
1957 3 4 9 6 2 1 0
1958 5 5 10 6 5 1 0
1959 7 6 13 6 5 2 0
1960 8 9 14 8 5 2 0
1961 8 11 14 10 6 2 0
1962 8 12 14 13 6 2 2
@dukevis
dukevis / basketball_data2.csv
Last active August 29, 2015 13:56
ACC Basketball Line Chart
Year Clem Duke MD UNC NCS UVA WF
1954 0 1 1 0 3 0 2
1955 0 3 1 0 6 1 3
1956 0 4 1 1 9 1 5
1957 0 4 2 3 9 1 6
1958 0 5 5 5 10 1 6
1959 0 6 5 7 13 2 6
1960 0 9 5 8 14 2 8
1961 0 11 6 8 14 2 10
1962 2 12 6 8 14 2 13
@dukevis
dukevis / index.html
Last active August 29, 2015 13:56
Remove Elements with Key Functions
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Title Here</title>
<script type="text/javascript" src="../d3.v3/d3.v3.js"></script>
<style type="text/css">
.axis path,
@dukevis
dukevis / index.html
Last active August 29, 2015 13:55
Add Value Bar Chart on Click
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Title Here</title>
<script type="text/javascript" src="../d3.v3/d3.v3.js"></script>