Skip to content

Instantly share code, notes, and snippets.

@cfarm
Last active December 6, 2016 18:39
Show Gist options
  • Save cfarm/fc68a0a1f3963a7697799ea97971c1ce to your computer and use it in GitHub Desktop.
Save cfarm/fc68a0a1f3963a7697799ea97971c1ce to your computer and use it in GitHub Desktop.
how i'm working with the data

Getting the data from Github

I am using d3's built in .csv method to get the data.

I save the data file url directly as a constant for right now. Later, I'm planning to provide an array or object with data urls (or use Github API to get them) so we can loop through each data file and generate the graph for each.

Formatting the data

I update some of the fields in the JS (not the original file) to make them easier to work with:

  1. make the number fields number type
  2. Change 'seasonally adjusted' to true and 'unadjusted' to false for easy conditionals
  3. Format the dates using the month column and some math from my formatDates.js util

Display the data on the SVG

Data gets added to the graph SVG four times as 4 different line elements: Unadjusted/Final ('unprojected'), Seasonally adjusted/Final, Unadjusted & Projected, Seasonally adjusted & Projected.

Calculate the projected data months

Calculate which months are projected data (=6 months of the data starting with the last month provided).

Add line + label for the projected data month cutoff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment