Skip to content

Instantly share code, notes, and snippets.

@gelicia
Created March 12, 2014 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gelicia/9497971 to your computer and use it in GitHub Desktop.
Save gelicia/9497971 to your computer and use it in GitHub Desktop.
MEI Data - State
{"description":"MEI Data - State","endpoint":"","display":"svg","public":true,"require":[{"name":"topojson2","url":"https://raw.github.com/mbostock/topojson/master/topojson.js"},{"name":"underscore","url":"http://underscorejs.org/underscore-min.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"obesity.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"us.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"MEIData.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/zT73MVr.png","ajax-caching":true,"inline-console":true}
var width = 749,height = 413;
var usTopology = tributary.us;
var meiData = tributary.MEIData;
var geometries = usTopology.objects.states.geometries;
var svg = d3.select("svg");
var map = svg.append("g").classed("map", true);
var projection = d3.geo.albersUsa()
.scale(706)
.translate([width / 2, height / 2]);
var colorScale = d3.scale.linear().domain([0, 60]).range(["#FFFFFF", "#0014FF"]);
var path = d3.geo.path().projection(projection);
var usTopFeatures = topojson.feature(usTopology, usTopology.objects.states).features;
console.log(topojson.feature(usTopology, usTopology.objects.states))
//this merges the data of the state's shape with the equality data of the state
usTopFeatures = usTopFeatures.map(function(d){
var outObj = d;
var stateData = _.find(meiData, function(dIn){return dIn.State == d.id;});
if (stateData !== undefined){
outObj.meiData = stateData;
}
return outObj;
});
map.selectAll("path").data(usTopFeatures).enter()
.append("path")
.attr({
d: path,
stroke: '#000',
id: function(d){return d.id;},
fill: function(d){ return d.meiData !== undefined ? colorScale(d.meiData['FinalScore-60']) : '#696969'; }
})
.on('click',function(d){console.log(d);});
State NonDiscriminationLaws-SexualOrientation-Employment-3 NonDiscriminationLaws-SexualOrientation-Housing-3 NonDiscriminationLaws-SexualOrientation-PublicAccommodations-3 RelationshipRecognition-SexualOrientation-MarriageEquality-12 RelationshipRecognition-SexualOrientation-CivilUnions-12 RelationshipRecognition-SexualOrientation-DomesticPartnerships-12 MunicipalServices-SexualOrientation-EnumeratedAntiBullyingSchoolPolicies-3 NonDiscriminationLaws-GenderIdentity-Employment-3 NonDiscriminationLaws-GenderIdentity-Housing-3 NonDiscriminationLaws-GenderIdentity-PublicAccommodations-3 MunicipalServices-GenderIdentity-EnumeratedAntiBullyingSchoolPolicies-3 FinalScore-60
Alabama 0 0 0 0 0 0 0 0 0 0 0 0
Alaska 0 0 0 0 0 0 0 0 0 0 0 0
Arizona 0 0 0 0 0 0 0 0 0 0 0 0
Arkansas 0 0 0 0 0 0 0 0 0 0 0 0
California 3 3 3 12 0 12 3 3 3 3 3 48
Colorado 3 3 3 0 12 0 3 3 3 3 3 36
Connecticut 3 3 3 12 0 0 3 3 3 3 3 36
Delaware 3 3 3 12 0 0 0 3 3 3 0 30
Florida 0 0 0 0 0 0 0 0 0 0 0 0
Georgia 0 0 0 0 0 0 0 0 0 0 0 0
Hawaii 3 3 3 0 12 0 3 3 3 3 3 36
Idaho 0 0 0 0 0 0 0 0 0 0 0 0
Illinois 3 3 3 0 12 0 3 3 3 3 3 36
Indiana 0 0 0 0 0 0 0 0 0 0 0 0
Iowa 3 3 3 12 0 0 3 3 3 3 3 36
Kansas 0 0 0 0 0 0 0 0 0 0 0 0
Kentucky 0 0 0 0 0 0 0 0 0 0 0 0
Louisiana 0 0 0 0 0 0 0 0 0 0 0 0
Maine 3 3 3 12 0 0 3 3 3 3 3 36
Maryland 3 3 3 12 0 0 3 0 0 0 3 27
Massachusetts 3 3 3 12 0 0 0 3 3 3 0 30
Michigan 0 0 0 0 0 0 0 0 0 0 0 0
Minnesota 3 3 3 12 0 0 0 3 3 3 0 30
Mississippi 0 0 0 0 0 0 0 0 0 0 0 0
Missouri 0 0 0 0 0 0 0 0 0 0 0 0
Montana 0 0 0 0 0 0 0 0 0 0 0 0
Nebraska 0 0 0 0 0 0 0 0 0 0 0 0
Nevada 3 3 3 0 0 12 0 3 3 3 0 30
New Hampshire 3 3 3 12 0 0 3 0 0 0 3 27
New Jersey 3 3 3 0 12 0 3 3 3 3 3 36
New Mexico 3 3 3 0 0 0 3 3 3 3 0 21
New York 3 3 3 12 0 0 3 0 0 0 3 27
North Carolina 0 0 0 0 0 0 3 0 0 0 3 6
North Dakota 0 0 0 0 0 0 0 0 0 0 0 0
Ohio 0 0 0 0 0 0 0 0 0 0 0 0
Oklahoma 0 0 0 0 0 0 0 0 0 0 0 0
Oregon 3 3 3 0 0 12 3 3 3 3 3 36
Pennsylvania 0 0 0 0 0 0 0 0 0 0 0 0
Rhode Island 3 3 3 12 0 0 0 3 3 3 0 30
South Carolina 0 0 0 0 0 0 0 0 0 0 0 0
South Dakota 0 0 0 0 0 0 0 0 0 0 0 0
Tennessee 0 0 0 0 0 0 0 0 0 0 0 0
Texas 0 0 0 0 0 0 0 0 0 0 0 0
Utah 0 0 0 0 0 0 0 0 0 0 0 0
Vermont 3 3 3 12 0 0 3 3 3 3 3 36
Virginia 0 0 0 0 0 0 0 0 0 0 0 0
Washington 3 3 3 12 0 0 3 3 3 3 3 36
West Virginia 0 0 0 0 0 0 0 0 0 0 0 0
Wisconsin 3 3 3 0 0 12 0 0 0 0 0 21
Wyoming 0 0 0 0 0 0 0 0 0 0 0 0
.map {
display: block;
position: absolute;
background: #fff;
width: 100%;
height: 100%;
margin: 0;
}
path.state {
stroke: #666;
stroke-width: .5;
}
path.state:hover {
stroke: #000;
}
Display the source blob
Display the rendered blob
Raw
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