Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View enactdev's full-sized avatar

Chris A. Williams enactdev

  • Enact Development
  • Washington, DC
View GitHub Profile
@enactdev
enactdev / README.md
Last active January 13, 2022 23:01 — forked from mbostock/.block
Responsive D3 chart

This is basic responsive D3 chart example. It is a fork from Mike Bostock's bar chart "Wrapping Long Labels." This NPR article was also useful.

Changes from Mike Bostock's original in the order they were applied:

  • Add default width and height
  • Use those defaults to calculate non-repsonsive width and height
  • Create the set_vars() function to re-calculate width and height when needed. Call it immediately to correctly set width and height
  • Put the code that draws the chart in a function, drawGraphic. Basically, the code from "var x..." through "svg.selectAll("rect")..."
  • Create the window.onresize funcion

In the future be able to create breakpoints to draw slightly different graphs if space is constrained.

@enactdev
enactdev / README.md
Last active January 10, 2020 21:27
Plotly JS Example

Plotly JS Example

@enactdev
enactdev / README.md
Last active May 2, 2019 08:44
Plotly JS Example Final

Plotly JS Example Final

@enactdev
enactdev / README.md
Last active July 30, 2018 16:44
Bears Ears changes: Obama to Trump

Bears Ears changes: Obama to Trump

This map shows Obama's Bears Ears National Monument outlined in black, with Trump's much smaller replacement overlaid in blue.

A full description of how I created this is available on my blog.

Short description: Files were downloaded from blm.gov, converted to GeoJSON with ogr2ogr, edited with QGIS, simplified with mapshaper.org, and displayed with Leaflet.

ogr2ogr -skipfailures -f "GeoJSON" -t_srs WGS84 bears_ears_obmama.json NLCS_NM_NCA_historic.gdb

Delaware Zipcode Map

@enactdev
enactdev / PA_Gerrymander_INDEX08_post_2011.csv
Created January 17, 2018 20:37
CSV file of post-2011 congressional districts in PA. INDEX08 is a calculated column used by Republicans while creating the new districts.
District INDEX08 Overview 2012 Dem % 2012 Rep % 2014 Dem % 2014 Rep % 2016 Dem % 2016 Rep %
1 -257.1486 Dem 85 15 82.9 17.1 82.2 17.8
2 -344.7353 Dem 89.4 9.4 87.7 12.3 90.2 9.8
3 80.1691 Rep 41.1 54.7 39.5 60.5 0 100
4 313.012 Rep 34.4 59.7 25.5 74.5 33.9 66.1
5 34.3353 Rep 37.1 62.9 36.4 63.6 32.8 67.2
6 108.2123 Rep 43 57 43.8 56.2 42.8 57.2
7 96.4877 Rep 40.5 59.5 38 62 40.5 59.5
8 29.2598 Rep 43.4 56.6 38.1 61.9 45.6 54.4
9 119.0247 Rep 38.4 61.6 36.4 63.6 36.7 63.3
@enactdev
enactdev / PA_Gerrymander_INDEX08_pre_2011.csv
Created January 17, 2018 19:08
CSV file of pre-2011 congressional districts in PA. INDEX08 is a calculated column used by Republicans while creating the new districts.
District INDEX08 Overview 2004 Dem % 2004 Rep % 2008 Dem % 2008 Rep % 2010 Dem % 2010 Rep %
1 -331.3499 Dem 86.2 13.4 90.8 9.2 100 0
2 -336.9645 Dem 88.1 11.9 88.9 11.1 89.3 10.7
3 30.9187 R-D-R 39.9 60.1 51.6 48.4 44.3 55.7
4 80.2518 R-D-D 35.8 63.2 55.9 44.1 50.8 49.2
5 78.8013 Rep 11.8 88.2 41.1 56.6 28.2 68.7
6 1.7053 Rep 49 51 47.9 52.1 42.9 57.1
7 24.6376 R-D-R 40.4 58.8 59.6 40.4 44 54.9
8 4.8812 R-D-R 43.3 55.3 56.8 41.7 46.5 53.5
9 232.8966 Rep 30.5 69.5 36.1 63.9 26.9 73.1
@enactdev
enactdev / index.html
Last active October 31, 2017 01:13
Data Products Week 3
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html>
<head>
<title>Philly Population</title>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="generator" content="pandoc" />
@enactdev
enactdev / index.html
Created October 30, 2017 01:24
Capstone Project: Milestone Report
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
@enactdev
enactdev / index.html
Created October 20, 2017 01:14
Leaflet map created with RStudio
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />