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 September 11, 2015 19:00 — forked from mbostock/.block
Website trackers on newssites
@enactdev
enactdev / README.md
Last active September 7, 2015 23:17 — forked from mbostock/.block
Knight Data Viz

Placeholder README.md

@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.