Skip to content

Instantly share code, notes, and snippets.

@ryanthejuggler
Created December 5, 2013 03:10
Show Gist options
  • Save ryanthejuggler/7799573 to your computer and use it in GitHub Desktop.
Save ryanthejuggler/7799573 to your computer and use it in GitHub Desktop.
US Data Visualization (with fake data)
var us;
var stateNames = {};
var stateIds = {};
var stateNamesByAbbr = {};
var stateAbbrById = {};
var g;
var data = {};
var year = 2013;
var width = 960,
height = 600,
centered;
var projection = d3.geo.albersUsa()
.scale(1070)
.translate([width / 2, (height-100) / 2]);
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var full = {
purple: '#54278f',
red: '#d60000',
blue: '#0000d6',
orange: '#DBA400'
};
var color = {};
color.purple = d3.scale.linear()
.domain([1,4])
.range(['#eeeeee',full.purple]);
color.red = d3.scale.linear()
.domain([1,4])
.range(['#f6eeee',full.red]);
color.blue = d3.scale.linear()
.domain([1,5])
.range(['#eeeeee',full.blue]);
color.orange = d3.scale.linear()
.domain([3,13])
.range(['#eeeeee',full.orange]);
var description = {
rel: ["","No rights", "Limited rights", "Civil union or domestic partnerships allowed", "Marriage equality", "No data"],
ban: ["","No law, statute or amendment","Statute banning marriage/relationship recognition","Constitutional amendment banning marriage","Statute banning same sex marriage recognition","No ban"],
inter: ["","No interstate relationship recognition","Divorce only","Civil unions only","Marriage only","All out-of-state unions recognized"]
};
function loadGeoData(){
d3.json("us.json", loadStateNames);
}
function loadStateNames(err, _us){
us = _us;
$.get("states.list", processStateNames);
}
function processStateNames(input){
input = input.split("\n");
for(var i=0;i<input.length;i++){
var spl = input[i].split(';');
if(spl.length<2) continue;
var name = spl[0];
var abbr = spl[1];
var id = i+1;
stateNames[id] = name;
stateIds[name] = id;
stateNamesByAbbr[abbr] = name;
stateAbbrById[id] = abbr;
}
$.get("fakedata.csv", loadData);
}
function getData(year, abbr){
var key = year+'-'+abbr;
return data[key];
}
function loadData(_data){
_data = _data.split('\n');
for(var i=0;i<_data.length;i++){
var row = _data[i].split(',');
var year = row[0];
var state = row[1];
var key = year+"-"+state;
data[key] = {
ban: parseInt(row[2]),
rel: parseInt(row[3]),
inter: parseInt(row[4])
};
console.log(key,data[key]);
data[key].sum = data[key].ban + data[key].rel + data[key].inter;
}
g = svg.append("g");
var sc2 = d3.scale.linear()
.domain([width-600,width-10])
.range([1996,2013]);
var t = d3.time.scale()
.domain([new Date(1996,0,1),new Date(2013,0,1)])
.range([width-600,width-10]);
var timeline = d3.svg.axis().scale(t)
.ticks(d3.time.year);
g.append("g")
.attr("class","timeline")
.attr("transform", "translate(0,"+(height-50)+")")
.call(timeline)
.selectAll('text')
.attr('y',0)
.attr('x',9)
.attr('dy','.35em')
.attr('transform','rotate(90)')
.style('text-anchor','start')
var slider = svg.append("g").append("circle")
.attr("cx",width-10)
.attr("cy",height-50)
.attr("r",8)
.style("cursor","ew-resize")
var menu = g.append("g").attr("class","menu");
var menuRect = menu.append("rect")
.attr("x", 10)
.attr("y", (height-75))
.attr("width", 300)
.attr("height", 50)
.attr("fill", full.purple)
var currentVar = menu.append("text")
.attr("x",20)
.attr("y", (height-36))
.attr("font-size","40px")
.text("Recognition")
menu.append("path")
.attr("d","M295,"+(height-55)+"L265,"+(height-55)+"L280,"+(height-40)+"Z")
.attr("fill","#0f0")
.attr("class","dropdn")
var yearDisplay = g.append("text")
.attr("x",width-300)
.attr("y",75)
.style("fill","#000")
.style("font-family","Roboto Slab")
.style("text-anchor","start")
.style("font-size","50px")
.text(2013)
var states = g.append("g")
.attr("id", "states");
states.selectAll("path")
.data(topojson.feature(us, us.objects.states).features)
.enter().append("path")
.attr("d", path)
.attr("title", function(d){
var dat = getData(2013,stateAbbrById[d.id]);
if(dat) dat = dat.rel;
else dat = 5;
return stateNames[d.id]+", 2013: "+description.rel[dat];
})
.style("fill", function(d){
var dat = getData(2013, stateAbbrById[d.id]);
if(dat)
return color.purple(dat.rel);
return '#eeeeee';
});
var menuDrop = g.append("g").attr("display","none");
var dropHeight = 150;
var menuDropRect = menuDrop.append("rect")
.attr("x",10)
.attr("y", height-75-dropHeight)
.attr("width",300)
.attr("height",dropHeight)
.attr("fill",color.purple(2));
var menuShowing = false;
var showMenu = function(b){
menuRect.transition()
.attr("fill",displayColor(fullScale));
menuDropRect.attr("fill",displayColor(fullScale*2/5));
d3.selectAll(".menu-item")
.transition()
.attr("fill",displayColor(fullScale));
menuDrop.attr("display",b?"inline":"none");
menuShowing = b;
};
function toggleMenu(){ showMenu(!menuShowing); };
menu.on("click",toggleMenu);
var displayVar = 'rel';
var displayColor = color.purple;
var fullScale = 5;
function updateVariable(idx){
var varMap = ['rel','inter','ban','sum'];
var colorMap = [color.purple, color.blue, color.red, color.orange];
displayVar = varMap[idx];
displayColor = colorMap[idx];
fullScale = (displayVar==='sum'?12:5);
setYear(year);
}
d3.selectAll(".tick text")
.style("cursor","pointer")
.on("click",function(){
year = parseInt(d3.event.target.textContent);
slider.transition()
.attr("cx",scale1(new Date(year,0,1)));
setYear(year);
});
var labels = ["Recognition of unions","Interstate recognition","Ban on unions","Total"];
var labelsShort = ["Recognition","Interstate","Bans","Total"];
for(var i=0;i<labels.length;i++){
(function(){
var j = i;
menuDrop.append("text")
.attr("x",20)
.attr("y",height-75-dropHeight+32*(j+1))
.attr("font-size","24px")
.attr("fill", color.purple(4))
.style("cursor","pointer")
.attr("class","menu-item")
.text(labels[j])
.on("click",function(){
currentVar.text(labelsShort[j]);
updateVariable(j);
showMenu(false);
});
})();
}
var year = 2013;
var mx0, cx0;
var usingSlider = false;
var snagSlider = function(e){
usingSlider = true;
cx0 = parseInt(slider.attr("cx"));
mx0 = d3.event.pageX;
d3.event.preventDefault();
return false;
};
scale1=t;
scale2=sc2;
var snapSlider = function(cx){
var yr = scale2(parseInt(cx));
yr = Math.round(yr);
if(yr<1996) yr=1996;
if(yr>2013) yr=2013;
if(yr===year) return;
setYear(yr);
var cx = scale1(new Date(yr,0,1));
slider
.attr("cx",cx);
};
var moveSlider = function(e){
if(!usingSlider) return;
var dx = d3.event.pageX - mx0;
var cx = cx0 + dx;
d3.event.preventDefault();
snapSlider(cx);
return false;
};
var releaseSlider = function(){
if(!usingSlider) return true;
usingSlider = false;
d3.event.preventDefault();
return false;
};
slider.on("mousedown",snagSlider);
svg.on("mousemove",moveSlider);
d3.select("body").on("mouseup",releaseSlider);
var setYear = function(yr){
year = yr;
states.selectAll("path")
.transition()
.attr("title", function(d){
var dat = getData(year,stateAbbrById[d.id]);
if(dat) dat = dat[displayVar];
else{ dat = {ban:1,inter:1,rel:1,sum:1}; dat = dat[displayVar]; }
var desc= Math.round(dat*100/12)+"%";
if(displayVar !== 'sum') desc = description[displayVar][dat]
return stateNames[d.id]+", "+year+": "+desc;
})
.style("fill", function(d){
var dat = getData(year, stateAbbrById[d.id]);
if(dat)
return displayColor(dat[displayVar]);
return '#eeeeee';
});
yearDisplay.text(year);
};
}
$(function(){
loadGeoData();
});
1996 AL 1 1 1
1996 AK 1 1 1
1996 AZ 1 1 1
1996 AR 1 1 1
1996 CA 1 1 1
1996 CO 1 1 1
1996 CT 1 1 1
1996 DE 1 1 1
1996 DC 2 1 1
1996 FL 1 1 1
1996 GA 1 1 2
1996 HI 1 1 2
1996 ID 1 1 1
1996 IL 1 1 1
1996 IN 1 1 1
1996 IA 2 1 1
1996 KS 1 1 1
1996 KY 2 1 1
1996 LA 1 1 1
1996 ME 1 1 1
1996 MD 1 1 1
1996 MA 1 1 1
1996 MI 2 1 1
1996 MN 1 1 1
1996 MS 1 1 1
1996 MO 1 2 1
1996 MT 1 1 1
1996 NE 1 1 1
1996 NV 1 1 1
1996 NH 1 1 1
1996 NJ 1 1 1
1996 NM 1 1 1
1996 NY 1 1 1
1996 NC 1 2 1
1996 ND 1 1 1
1996 OH 1 1 1
1996 OK 1 1 1
1996 OR 1 1 2
1996 PA 1 1 1
1996 PR 2 1 2
1996 RI 1 2 1
1996 SC 1 1 1
1996 SD 1 1 1
1996 TN 2 1 1
1996 TX 2 1 1
1996 UT 1 2 1
1996 VT 1 2 1
1996 VA 1 1 1
1996 WA 1 1 1
1996 WV 1 1 1
1996 WI 2 1 1
1996 WY 1 1 1
1997 AL 1 1 1
1997 AK 1 2 1
1997 AZ 1 1 1
1997 AR 1 1 1
1997 CA 1 1 1
1997 CO 1 1 1
1997 CT 1 1 1
1997 DE 1 1 1
1997 DC 2 1 1
1997 FL 2 1 2
1997 GA 1 2 2
1997 HI 1 1 2
1997 ID 1 1 1
1997 IL 1 1 1
1997 IN 1 1 1
1997 IA 2 1 1
1997 KS 2 1 1
1997 KY 2 1 1
1997 LA 1 2 1
1997 ME 1 1 1
1997 MD 1 1 1
1997 MA 2 1 1
1997 MI 2 1 1
1997 MN 1 2 1
1997 MS 1 1 1
1997 MO 2 2 2
1997 MT 1 1 1
1997 NE 1 1 1
1997 NV 1 2 1
1997 NH 1 1 1
1997 NJ 1 1 1
1997 NM 1 1 1
1997 NY 1 1 1
1997 NC 1 2 1
1997 ND 1 2 2
1997 OH 1 1 1
1997 OK 1 1 1
1997 OR 1 1 2
1997 PA 1 1 1
1997 PR 3 1 2
1997 RI 1 2 1
1997 SC 1 1 1
1997 SD 1 1 2
1997 TN 3 1 1
1997 TX 2 2 1
1997 UT 1 2 2
1997 VT 1 2 1
1997 VA 1 1 1
1997 WA 1 2 1
1997 WV 1 1 1
1997 WI 2 1 1
1997 WY 1 1 1
1998 AL 1 1 1
1998 AK 1 3 1
1998 AZ 1 1 1
1998 AR 1 1 1
1998 CA 2 1 1
1998 CO 1 1 1
1998 CT 1 1 1
1998 DE 1 1 1
1998 DC 2 1 2
1998 FL 2 1 2
1998 GA 1 2 2
1998 HI 1 1 2
1998 ID 1 1 2
1998 IL 1 1 1
1998 IN 1 1 1
1998 IA 2 2 1
1998 KS 2 1 1
1998 KY 2 1 2
1998 LA 1 2 1
1998 ME 1 1 1
1998 MD 1 1 1
1998 MA 2 1 1
1998 MI 2 2 1
1998 MN 1 2 1
1998 MS 1 1 1
1998 MO 2 2 2
1998 MT 1 1 1
1998 NE 1 1 1
1998 NV 1 2 2
1998 NH 1 1 1
1998 NJ 1 1 1
1998 NM 1 1 1
1998 NY 1 1 1
1998 NC 1 2 1
1998 ND 1 3 2
1998 OH 1 1 1
1998 OK 1 1 1
1998 OR 1 1 3
1998 PA 1 1 1
1998 PR 3 1 2
1998 RI 1 2 1
1998 SC 2 1 1
1998 SD 2 1 2
1998 TN 3 1 1
1998 TX 2 3 1
1998 UT 1 2 2
1998 VT 1 2 1
1998 VA 1 1 2
1998 WA 1 2 1
1998 WV 2 1 1
1998 WI 3 1 1
1998 WY 1 1 1
1999 AL 2 2 1
1999 AK 1 3 1
1999 AZ 1 1 1
1999 AR 1 1 1
1999 CA 2 2 1
1999 CO 2 1 1
1999 CT 1 1 1
1999 DE 1 1 1
1999 DC 2 1 2
1999 FL 2 1 2
1999 GA 1 2 2
1999 HI 1 1 2
1999 ID 1 1 2
1999 IL 1 1 1
1999 IN 1 1 1
1999 IA 3 2 1
1999 KS 2 1 1
1999 KY 2 1 2
1999 LA 1 2 1
1999 ME 1 1 1
1999 MD 1 1 1
1999 MA 2 1 1
1999 MI 2 2 1
1999 MN 1 2 1
1999 MS 1 1 1
1999 MO 2 2 2
1999 MT 1 1 1
1999 NE 1 1 1
1999 NV 1 2 2
1999 NH 1 1 1
1999 NJ 1 1 2
1999 NM 1 1 1
1999 NY 1 1 1
1999 NC 2 2 1
1999 ND 1 3 2
1999 OH 1 2 1
1999 OK 1 1 1
1999 OR 1 1 4
1999 PA 1 1 1
1999 PR 3 2 2
1999 RI 1 2 1
1999 SC 2 2 1
1999 SD 2 1 3
1999 TN 3 2 1
1999 TX 2 3 1
1999 UT 1 2 2
1999 VT 1 2 1
1999 VA 1 1 2
1999 WA 1 2 1
1999 WV 2 1 1
1999 WI 3 1 1
1999 WY 2 1 1
2000 AL 2 2 1
2000 AK 1 3 1
2000 AZ 1 1 1
2000 AR 1 1 1
2000 CA 2 2 1
2000 CO 2 1 1
2000 CT 1 2 1
2000 DE 2 1 2
2000 DC 2 1 2
2000 FL 3 1 2
2000 GA 1 2 2
2000 HI 1 1 2
2000 ID 1 1 2
2000 IL 1 1 1
2000 IN 1 1 1
2000 IA 3 2 1
2000 KS 2 2 1
2000 KY 2 1 2
2000 LA 1 2 1
2000 ME 1 1 1
2000 MD 1 1 1
2000 MA 2 1 1
2000 MI 2 2 1
2000 MN 1 2 1
2000 MS 1 1 1
2000 MO 2 2 2
2000 MT 1 2 1
2000 NE 1 1 1
2000 NV 1 2 2
2000 NH 1 2 1
2000 NJ 1 1 3
2000 NM 1 1 1
2000 NY 2 1 2
2000 NC 2 2 1
2000 ND 1 3 2
2000 OH 2 2 1
2000 OK 1 1 1
2000 OR 2 1 4
2000 PA 1 2 1
2000 PR 3 2 3
2000 RI 2 2 1
2000 SC 2 2 1
2000 SD 2 1 3
2000 TN 3 2 1
2000 TX 2 3 1
2000 UT 1 2 2
2000 VT 1 2 2
2000 VA 2 1 2
2000 WA 1 2 2
2000 WV 2 1 1
2000 WI 3 1 1
2000 WY 2 1 1
2001 AL 2 3 2
2001 AK 1 3 2
2001 AZ 1 1 1
2001 AR 1 1 1
2001 CA 3 2 1
2001 CO 2 1 1
2001 CT 1 2 1
2001 DE 2 1 2
2001 DC 3 2 2
2001 FL 3 1 2
2001 GA 2 3 2
2001 HI 1 1 2
2001 ID 1 1 2
2001 IL 1 1 1
2001 IN 1 1 1
2001 IA 3 2 1
2001 KS 2 2 1
2001 KY 2 1 2
2001 LA 1 2 1
2001 ME 1 1 1
2001 MD 1 1 1
2001 MA 2 2 1
2001 MI 2 2 1
2001 MN 1 2 1
2001 MS 1 2 2
2001 MO 3 3 2
2001 MT 1 2 1
2001 NE 1 1 1
2001 NV 1 2 2
2001 NH 1 2 1
2001 NJ 1 1 3
2001 NM 1 1 1
2001 NY 2 1 2
2001 NC 2 2 1
2001 ND 1 3 2
2001 OH 2 2 1
2001 OK 1 1 1
2001 OR 3 1 4
2001 PA 2 2 1
2001 PR 3 2 4
2001 RI 2 2 1
2001 SC 2 2 2
2001 SD 2 1 3
2001 TN 3 2 1
2001 TX 2 3 1
2001 UT 1 3 2
2001 VT 1 2 2
2001 VA 2 1 3
2001 WA 1 2 2
2001 WV 2 1 1
2001 WI 3 1 1
2001 WY 2 1 1
2002 AL 2 4 2
2002 AK 1 3 2
2002 AZ 2 1 1
2002 AR 1 1 1
2002 CA 3 2 1
2002 CO 2 1 1
2002 CT 2 2 1
2002 DE 2 1 2
2002 DC 3 3 2
2002 FL 3 1 3
2002 GA 2 3 2
2002 HI 1 1 2
2002 ID 1 1 2
2002 IL 1 1 1
2002 IN 1 1 1
2002 IA 3 2 1
2002 KS 2 3 1
2002 KY 2 1 2
2002 LA 2 2 1
2002 ME 1 1 1
2002 MD 1 1 1
2002 MA 2 2 1
2002 MI 2 2 1
2002 MN 1 2 1
2002 MS 1 2 2
2002 MO 3 3 2
2002 MT 1 2 1
2002 NE 1 1 1
2002 NV 1 2 2
2002 NH 1 2 1
2002 NJ 1 1 3
2002 NM 2 1 1
2002 NY 2 1 2
2002 NC 2 2 1
2002 ND 1 3 2
2002 OH 2 2 1
2002 OK 1 1 1
2002 OR 3 1 4
2002 PA 2 3 1
2002 PR 3 2 4
2002 RI 2 2 1
2002 SC 2 2 2
2002 SD 2 1 3
2002 TN 3 2 2
2002 TX 2 3 1
2002 UT 1 4 2
2002 VT 1 2 2
2002 VA 2 1 3
2002 WA 1 2 2
2002 WV 2 1 2
2002 WI 3 1 1
2002 WY 2 1 1
2003 AL 2 4 2
2003 AK 1 3 2
2003 AZ 2 1 1
2003 AR 1 1 1
2003 CA 3 2 2
2003 CO 2 1 1
2003 CT 2 2 1
2003 DE 2 1 2
2003 DC 3 3 2
2003 FL 3 1 3
2003 GA 2 3 3
2003 HI 1 1 2
2003 ID 1 1 2
2003 IL 1 1 1
2003 IN 2 1 1
2003 IA 3 2 1
2003 KS 2 3 1
2003 KY 2 1 2
2003 LA 2 2 1
2003 ME 1 1 1
2003 MD 1 1 1
2003 MA 2 2 1
2003 MI 2 2 1
2003 MN 1 2 1
2003 MS 1 3 2
2003 MO 3 3 2
2003 MT 1 2 1
2003 NE 1 1 1
2003 NV 1 2 2
2003 NH 1 2 1
2003 NJ 1 1 3
2003 NM 2 1 1
2003 NY 2 1 2
2003 NC 2 2 1
2003 ND 1 3 2
2003 OH 2 2 1
2003 OK 2 1 1
2003 OR 3 1 4
2003 PA 2 3 1
2003 PR 3 2 5
2003 RI 2 2 1
2003 SC 2 2 2
2003 SD 3 1 3
2003 TN 3 2 2
2003 TX 2 3 1
2003 UT 1 4 2
2003 VT 1 2 2
2003 VA 2 1 4
2003 WA 1 2 2
2003 WV 2 1 3
2003 WI 3 1 2
2003 WY 2 1 1
2004 AL 2 4 2
2004 AK 1 3 2
2004 AZ 2 2 1
2004 AR 2 1 2
2004 CA 3 2 2
2004 CO 2 1 1
2004 CT 2 2 2
2004 DE 2 1 2
2004 DC 3 3 2
2004 FL 3 1 3
2004 GA 2 3 3
2004 HI 1 1 2
2004 ID 1 1 2
2004 IL 1 1 1
2004 IN 3 1 1
2004 IA 3 2 2
2004 KS 2 3 1
2004 KY 2 1 2
2004 LA 3 2 1
2004 ME 2 1 2
2004 MD 1 1 1
2004 MA 2 2 1
2004 MI 2 2 1
2004 MN 1 3 1
2004 MS 1 3 2
2004 MO 3 3 2
2004 MT 1 2 1
2004 NE 1 1 1
2004 NV 1 2 3
2004 NH 1 2 1
2004 NJ 1 1 3
2004 NM 2 2 1
2004 NY 2 1 2
2004 NC 2 2 1
2004 ND 1 3 3
2004 OH 3 2 1
2004 OK 2 1 1
2004 OR 3 2 4
2004 PA 2 3 1
2004 PR 3 3 5
2004 RI 3 2 1
2004 SC 2 3 2
2004 SD 3 1 4
2004 TN 3 2 2
2004 TX 2 3 1
2004 UT 1 4 2
2004 VT 1 2 2
2004 VA 2 1 4
2004 WA 1 3 2
2004 WV 2 1 4
2004 WI 3 1 2
2004 WY 3 1 1
2005 AL 2 4 3
2005 AK 1 3 2
2005 AZ 2 2 1
2005 AR 2 1 3
2005 CA 3 2 2
2005 CO 3 2 1
2005 CT 2 2 2
2005 DE 2 1 2
2005 DC 3 3 2
2005 FL 3 1 3
2005 GA 2 3 3
2005 HI 1 1 2
2005 ID 1 1 3
2005 IL 1 1 1
2005 IN 3 1 1
2005 IA 3 3 3
2005 KS 2 3 1
2005 KY 2 1 2
2005 LA 3 2 1
2005 ME 2 1 2
2005 MD 2 1 1
2005 MA 2 2 1
2005 MI 2 2 1
2005 MN 2 3 1
2005 MS 2 3 2
2005 MO 3 3 2
2005 MT 1 2 1
2005 NE 1 1 1
2005 NV 1 2 3
2005 NH 1 2 1
2005 NJ 1 1 3
2005 NM 2 2 1
2005 NY 2 1 2
2005 NC 2 2 1
2005 ND 1 3 3
2005 OH 3 3 1
2005 OK 2 1 2
2005 OR 3 3 4
2005 PA 2 3 1
2005 PR 3 3 5
2005 RI 3 2 1
2005 SC 2 3 2
2005 SD 3 1 4
2005 TN 3 2 2
2005 TX 2 3 1
2005 UT 1 4 2
2005 VT 1 2 2
2005 VA 2 1 4
2005 WA 2 3 3
2005 WV 2 1 4
2005 WI 3 1 2
2005 WY 3 1 1
2006 AL 2 4 3
2006 AK 1 3 2
2006 AZ 2 2 2
2006 AR 2 1 3
2006 CA 3 2 2
2006 CO 3 2 1
2006 CT 2 2 2
2006 DE 2 1 2
2006 DC 3 3 2
2006 FL 3 2 3
2006 GA 3 3 3
2006 HI 1 1 2
2006 ID 1 1 3
2006 IL 1 1 1
2006 IN 3 1 1
2006 IA 3 3 3
2006 KS 3 3 1
2006 KY 2 1 2
2006 LA 3 2 1
2006 ME 2 1 2
2006 MD 2 1 1
2006 MA 2 2 1
2006 MI 2 2 2
2006 MN 2 3 1
2006 MS 2 3 2
2006 MO 3 3 2
2006 MT 1 2 1
2006 NE 1 1 1
2006 NV 1 2 3
2006 NH 1 2 2
2006 NJ 2 2 4
2006 NM 2 2 1
2006 NY 2 1 2
2006 NC 2 3 1
2006 ND 1 3 3
2006 OH 3 4 1
2006 OK 2 2 2
2006 OR 3 3 4
2006 PA 2 3 1
2006 PR 3 3 5
2006 RI 3 2 1
2006 SC 2 3 2
2006 SD 3 1 4
2006 TN 3 2 2
2006 TX 2 3 1
2006 UT 2 4 2
2006 VT 2 2 2
2006 VA 2 1 4
2006 WA 3 4 3
2006 WV 3 1 4
2006 WI 3 1 2
2006 WY 3 1 2
2007 AL 2 4 4
2007 AK 1 3 2
2007 AZ 2 2 2
2007 AR 2 1 3
2007 CA 3 2 2
2007 CO 3 2 2
2007 CT 2 3 2
2007 DE 2 1 2
2007 DC 3 3 2
2007 FL 3 2 4
2007 GA 3 4 3
2007 HI 2 1 2
2007 ID 1 1 3
2007 IL 1 1 1
2007 IN 3 1 1
2007 IA 4 3 3
2007 KS 3 3 1
2007 KY 2 1 2
2007 LA 3 2 1
2007 ME 2 1 2
2007 MD 2 1 1
2007 MA 2 2 1
2007 MI 3 2 2
2007 MN 2 3 1
2007 MS 2 4 2
2007 MO 3 3 3
2007 MT 1 2 1
2007 NE 1 1 1
2007 NV 1 2 3
2007 NH 1 2 2
2007 NJ 2 2 4
2007 NM 2 2 1
2007 NY 2 1 2
2007 NC 2 3 1
2007 ND 1 3 3
2007 OH 3 4 1
2007 OK 2 2 2
2007 OR 3 3 5
2007 PA 2 3 1
2007 PR 3 3 5
2007 RI 3 3 1
2007 SC 2 3 2
2007 SD 3 1 4
2007 TN 3 2 2
2007 TX 2 3 1
2007 UT 2 4 2
2007 VT 2 3 2
2007 VA 2 1 4
2007 WA 3 4 3
2007 WV 3 1 4
2007 WI 3 1 2
2007 WY 3 1 2
2008 AL 2 4 4
2008 AK 1 3 2
2008 AZ 2 2 2
2008 AR 2 1 3
2008 CA 3 2 2
2008 CO 3 2 2
2008 CT 2 3 2
2008 DE 2 1 2
2008 DC 3 4 2
2008 FL 3 2 4
2008 GA 3 4 3
2008 HI 2 1 3
2008 ID 1 1 3
2008 IL 1 1 1
2008 IN 3 1 1
2008 IA 5 3 3
2008 KS 3 3 1
2008 KY 2 1 2
2008 LA 3 2 1
2008 ME 2 1 3
2008 MD 2 1 1
2008 MA 2 2 1
2008 MI 3 2 2
2008 MN 2 3 1
2008 MS 2 4 2
2008 MO 3 3 3
2008 MT 1 2 1
2008 NE 1 1 2
2008 NV 1 2 3
2008 NH 1 2 2
2008 NJ 2 2 4
2008 NM 3 2 1
2008 NY 2 1 2
2008 NC 2 3 1
2008 ND 1 3 3
2008 OH 4 4 1
2008 OK 2 2 2
2008 OR 3 4 5
2008 PA 2 3 1
2008 PR 3 3 5
2008 RI 3 4 1
2008 SC 2 3 2
2008 SD 3 1 4
2008 TN 3 2 2
2008 TX 2 3 1
2008 UT 2 4 2
2008 VT 2 3 2
2008 VA 2 1 5
2008 WA 4 4 3
2008 WV 3 1 4
2008 WI 3 1 2
2008 WY 3 1 3
2009 AL 2 4 4
2009 AK 1 3 2
2009 AZ 2 2 2
2009 AR 2 1 3
2009 CA 3 2 2
2009 CO 3 2 2
2009 CT 3 3 2
2009 DE 3 1 2
2009 DC 3 4 2
2009 FL 3 2 4
2009 GA 3 4 3
2009 HI 3 1 4
2009 ID 1 2 4
2009 IL 1 1 1
2009 IN 3 1 1
2009 IA 5 3 4
2009 KS 3 3 1
2009 KY 2 1 2
2009 LA 3 2 1
2009 ME 3 1 3
2009 MD 2 1 1
2009 MA 2 2 1
2009 MI 3 2 2
2009 MN 2 3 1
2009 MS 2 4 2
2009 MO 3 3 3
2009 MT 1 2 1
2009 NE 1 1 2
2009 NV 1 2 3
2009 NH 1 2 2
2009 NJ 2 2 4
2009 NM 4 2 1
2009 NY 2 1 2
2009 NC 2 3 1
2009 ND 1 3 3
2009 OH 4 4 1
2009 OK 2 2 3
2009 OR 3 4 5
2009 PA 2 3 1
2009 PR 3 3 5
2009 RI 3 4 1
2009 SC 2 4 2
2009 SD 3 2 4
2009 TN 3 2 2
2009 TX 2 3 1
2009 UT 2 4 2
2009 VT 2 3 2
2009 VA 2 2 5
2009 WA 4 4 3
2009 WV 3 1 4
2009 WI 3 1 2
2009 WY 3 1 3
2010 AL 3 4 5
2010 AK 1 3 2
2010 AZ 2 3 2
2010 AR 2 1 3
2010 CA 3 2 2
2010 CO 3 2 2
2010 CT 3 3 2
2010 DE 3 1 2
2010 DC 3 4 3
2010 FL 3 2 5
2010 GA 4 4 3
2010 HI 3 1 4
2010 ID 1 2 4
2010 IL 1 1 1
2010 IN 3 2 1
2010 IA 5 3 4
2010 KS 3 3 1
2010 KY 2 1 2
2010 LA 3 2 1
2010 ME 3 1 3
2010 MD 2 1 1
2010 MA 2 2 1
2010 MI 3 2 2
2010 MN 2 3 1
2010 MS 3 4 2
2010 MO 3 3 3
2010 MT 1 2 2
2010 NE 1 1 2
2010 NV 1 2 3
2010 NH 1 2 2
2010 NJ 2 2 4
2010 NM 4 2 1
2010 NY 2 1 2
2010 NC 2 3 1
2010 ND 1 3 3
2010 OH 4 4 1
2010 OK 2 2 3
2010 OR 3 4 5
2010 PA 2 3 1
2010 PR 3 3 5
2010 RI 3 4 1
2010 SC 3 4 2
2010 SD 3 2 4
2010 TN 3 2 2
2010 TX 2 3 2
2010 UT 2 4 3
2010 VT 2 3 2
2010 VA 2 2 5
2010 WA 4 4 3
2010 WV 4 1 4
2010 WI 3 1 2
2010 WY 4 1 3
2011 AL 3 4 5
2011 AK 1 3 2
2011 AZ 2 3 2
2011 AR 2 1 3
2011 CA 3 2 3
2011 CO 3 2 2
2011 CT 3 3 2
2011 DE 3 1 3
2011 DC 3 4 4
2011 FL 3 2 5
2011 GA 4 4 3
2011 HI 3 1 5
2011 ID 1 3 4
2011 IL 1 1 1
2011 IN 3 2 1
2011 IA 5 3 4
2011 KS 3 3 1
2011 KY 2 1 2
2011 LA 3 2 1
2011 ME 3 1 3
2011 MD 2 1 1
2011 MA 2 3 1
2011 MI 3 2 2
2011 MN 3 3 1
2011 MS 3 4 2
2011 MO 3 3 3
2011 MT 1 3 2
2011 NE 1 1 2
2011 NV 2 2 3
2011 NH 2 2 2
2011 NJ 2 2 4
2011 NM 4 2 1
2011 NY 2 1 2
2011 NC 2 3 2
2011 ND 1 3 3
2011 OH 4 4 1
2011 OK 2 2 4
2011 OR 3 4 5
2011 PA 2 3 1
2011 PR 3 3 5
2011 RI 3 4 1
2011 SC 3 4 2
2011 SD 3 2 4
2011 TN 3 2 2
2011 TX 2 3 3
2011 UT 2 4 3
2011 VT 2 3 2
2011 VA 2 2 5
2011 WA 4 4 3
2011 WV 5 1 4
2011 WI 3 1 2
2011 WY 5 1 3
2012 AL 3 4 5
2012 AK 1 3 2
2012 AZ 2 3 2
2012 AR 2 1 3
2012 CA 3 3 3
2012 CO 3 2 2
2012 CT 3 3 2
2012 DE 3 1 3
2012 DC 3 4 4
2012 FL 3 2 5
2012 GA 4 4 3
2012 HI 3 1 5
2012 ID 1 3 4
2012 IL 1 2 1
2012 IN 3 2 1
2012 IA 5 3 4
2012 KS 3 3 1
2012 KY 2 1 3
2012 LA 4 2 1
2012 ME 3 2 3
2012 MD 3 1 1
2012 MA 2 3 1
2012 MI 3 2 2
2012 MN 3 3 1
2012 MS 3 4 2
2012 MO 3 3 3
2012 MT 1 3 2
2012 NE 1 1 2
2012 NV 2 2 3
2012 NH 2 2 2
2012 NJ 2 2 4
2012 NM 4 2 1
2012 NY 2 2 2
2012 NC 2 3 2
2012 ND 1 3 3
2012 OH 4 4 1
2012 OK 2 2 4
2012 OR 3 4 5
2012 PA 2 3 1
2012 PR 3 3 5
2012 RI 4 4 1
2012 SC 3 4 2
2012 SD 3 2 4
2012 TN 3 2 2
2012 TX 2 3 3
2012 UT 2 4 3
2012 VT 3 3 2
2012 VA 2 2 5
2012 WA 4 4 4
2012 WV 5 1 4
2012 WI 3 2 2
2012 WY 5 2 3
2013 AL 3 4 5
2013 AK 1 3 2
2013 AZ 2 3 2
2013 AR 2 1 3
2013 CA 3 3 3
2013 CO 3 2 2
2013 CT 3 3 2
2013 DE 3 1 3
2013 DC 3 4 4
2013 FL 4 2 5
2013 GA 4 4 3
2013 HI 3 1 5
2013 ID 1 3 4
2013 IL 1 2 1
2013 IN 3 2 1
2013 IA 5 3 4
2013 KS 3 3 1
2013 KY 2 1 3
2013 LA 4 2 1
2013 ME 3 2 3
2013 MD 3 1 1
2013 MA 3 3 1
2013 MI 3 2 2
2013 MN 3 3 1
2013 MS 3 4 2
2013 MO 3 3 3
2013 MT 1 3 2
2013 NE 1 2 2
2013 NV 2 2 3
2013 NH 2 3 3
2013 NJ 2 2 4
2013 NM 4 2 1
2013 NY 2 2 2
2013 NC 2 3 2
2013 ND 1 3 4
2013 OH 4 4 1
2013 OK 2 2 4
2013 OR 3 4 5
2013 PA 2 3 1
2013 PR 3 3 5
2013 RI 4 4 1
2013 SC 3 4 2
2013 SD 3 2 4
2013 TN 3 3 2
2013 TX 2 3 3
2013 UT 2 4 3
2013 VT 3 3 2
2013 VA 2 2 5
2013 WA 4 4 4
2013 WV 5 1 4
2013 WI 3 2 2
2013 WY 5 2 3
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Cost of stigma</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>
<script src="data.js"></script>
</body>
</html>
Alabama;AL
Alaska;AK
American Samoa
Arizona;AZ
Arkansas;AR
California;CA
Colorado;CO
Connecticut;CT
Delaware;DE
District of Columbia;DC
Florida;FL
Georgia;GA
Guam
Hawaii;HI
Idaho;ID
Illinois;IL
Indiana;IN
Iowa;IA
Kansas;KS
Kentucky;KY
Louisiana;LA
Maine;ME
Maryland;MD
Massachusetts;MA
Michigan;MI
Minnesota;MN
Mississippi;MS
Missouri;MO
Montana;MT
Nebraska;NE
Nevada;NV
New Hampshire;NH
New Jersey;NJ
New Mexico;NM
New York;NY
North Carolina;NC
North Dakota;ND
Ohio;OH
Oklahoma;OK
Oregon;OR
Pennsylvania;PA
Puerto Rico;PR
Rhode Island;RI
South Carolina;SC
South Dakota;SD
Tennessee;TN
Texas;TX
Utah;UT
Vermont;VT
Virginia;VA
Virgin Islands
Washington;WA
West Virginia;WV
Wisconsin;WI
Wyoming;WY
@import url(http://fonts.googleapis.com/css?family=Roboto+Slab:400,700);
path {
fill: #ccc;
stroke: #fff;
stroke-linejoin: round;
}
body {
text-align: center;
font-family: Roboto Slab;
}
.timeline line,
.timeline path {
stroke: #000;
shape-rendering: crispEdges;
fill: none;
}
.menu,
.menu text {
fill: #fff;
font-family: Roboto Slab;
font-weight: bold;
font-variant: italic;
text-anchor: start
font-size: 48px;
}
.menu,
.menu text,
.menu path{
cursor: pointer;
}
.menu text,
.menu path{
fill: #fff;
}
.dropdn {
fill: #fff;
stroke: #fff;
}
.menu-item:hover{
fill: #fff;
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment