Skip to content

Instantly share code, notes, and snippets.

@metasyn
Created July 22, 2015 06:21
Show Gist options
  • Save metasyn/30d8f8dd08e26c929e22 to your computer and use it in GitHub Desktop.
Save metasyn/30d8f8dd08e26c929e22 to your computer and use it in GitHub Desktop.
fatal police shootings in 2015 (as of July)
<!doctype html>
<meta charset="utf-8">
<!--
fatal police shootings
This data came from the Washington Post's repo
https://github.com/washingtonpost/data-police-shootings
It is a database of every fatal shooting in the United States
by a police officer in the line of duty in 2015.
The numbers represent the number of people killed.
July 21st, 2015
xander johnson
http://metasyn.pw
-->
<!-- load D3js -->
<script src="http://www.d3plus.org/js/d3.js"></script>
<!-- load topojson library -->
<script src="http://www.d3plus.org/js/topojson.js"></script>
<!-- load D3plus after D3js -->
<script src="http://www.d3plus.org/js/d3plus.js"></script>
<!-- create container element for visualization -->
<div id="viz"></div>
<script>
var d = [{"STUSPS10":"AK","value":1,"id":"02"},{"STUSPS10":"AL","value":9,"id":"01"},{"STUSPS10":"AR","value":4,"id":"05"},{"STUSPS10":"AZ","value":27,"id":"04"},{"STUSPS10":"CA","value":74,"id":"06"},{"STUSPS10":"CO","value":14,"id":"08"},{"STUSPS10":"DC","value":1,"id":"11"},{"STUSPS10":"DE","value":2,"id":"10"},{"STUSPS10":"FL","value":28,"id":"12"},{"STUSPS10":"GA","value":13,"id":"13"},{"STUSPS10":"HI","value":1,"id":"15"},{"STUSPS10":"IA","value":3,"id":"19"},{"STUSPS10":"ID","value":4,"id":"16"},{"STUSPS10":"IL","value":11,"id":"17"},{"STUSPS10":"IN","value":11,"id":"18"},{"STUSPS10":"KS","value":6,"id":"20"},{"STUSPS10":"KY","value":6,"id":"21"},{"STUSPS10":"LA","value":10,"id":"22"},{"STUSPS10":"MA","value":6,"id":"25"},{"STUSPS10":"MD","value":8,"id":"24"},{"STUSPS10":"ME","value":1,"id":"23"},{"STUSPS10":"MI","value":8,"id":"26"},{"STUSPS10":"MN","value":5,"id":"27"},{"STUSPS10":"MO","value":10,"id":"29"},{"STUSPS10":"MS","value":4,"id":"28"},{"STUSPS10":"MT","value":2,"id":"30"},{"STUSPS10":"NC","value":11,"id":"37"},{"STUSPS10":"ND","value":1,"id":"38"},{"STUSPS10":"NE","value":5,"id":"31"},{"STUSPS10":"NH","value":1,"id":"33"},{"STUSPS10":"NJ","value":9,"id":"34"},{"STUSPS10":"NM","value":7,"id":"35"},{"STUSPS10":"NV","value":3,"id":"32"},{"STUSPS10":"NY","value":13,"id":"36"},{"STUSPS10":"OH","value":11,"id":"39"},{"STUSPS10":"OK","value":19,"id":"40"},{"STUSPS10":"OR","value":9,"id":"41"},{"STUSPS10":"PA","value":8,"id":"42"},{"STUSPS10":"SC","value":9,"id":"45"},{"STUSPS10":"TN","value":7,"id":"47"},{"STUSPS10":"TX","value":51,"id":"48"},{"STUSPS10":"UT","value":5,"id":"49"},{"STUSPS10":"VA","value":8,"id":"51"},{"STUSPS10":"WA","value":8,"id":"53"},{"STUSPS10":"WI","value":5,"id":"55"},{"STUSPS10":"WV","value":3,"id":"54"},{"STUSPS10":"WY","value":1,"id":"56"}]
var visualization = d3plus.viz()
.data(d) // data points
.container("#viz") // container
.coords("./state.json") // topojson
.type("geo_map")
.text("value")
.id("id") // shared key between topo / data
.tooltip(["STUSPS", "value"])
.color("value")
.draw()
</script>
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