I decided to make an R package to facilitate the reuse of charts I make for the blog and am going to develop it out in the open. Since I’ve settled on a style guide, a custom charting library helps avoid hunting down old scripts and copy pasting code all the time. You are welcome to use it, though be warned it will be entirely unstable as I settle on what options to make available and it comes as is.
If you haven’t already read it, a better place to start might be the basic introduction to my responsive D3 code organization strategy. That one covers only how to code a responsive x-axis and introduces the “calc”, “update”, “draw”, and “resize” functions that I use to keep things straight in D3. This post extends that to a full chart and introduces a “load” function for bringing in data from a csv file.
Coming up with contingency plans for different display dimensions in D3 can get ugly. My recent charts all adjust for screen size, but they also have to handle different modes and view options as selected by users. I’ve quickly realized the advantages of using well-planned functions for almost everything including establishing scales, adding elements to the DOM, and modifying elements of the DOM.
Say you want to put out an interactive visualization. This interactive needs access to a lot of data that’s too much to load into the browser all at once. Say you don’t want to run a database server for client queries on this data.
Messing around with the Bureau of Labor Statistics API in R earlier this week, I noticed there were no Node examples in the BLS documentation. Nothing fancy here, just supplementing those examples. Either use with Lambda to upload to S3, or locally and save to your file system.