Source: Office of Management and Budget, Tables 14-3 through 14-39. 2018 Budget State-by-State Tables
This Sankey shows the flow of obligation data for select U.S. Federal Government grant programs on a state-by-state basis. These data are actuals and estimates from the FY 2018 President's Budget.
The Sankey employs a few novel features:
utilizes Crossfilter for fast n-dimensional filtering across multiple variables within the data set
transforms tabular data into a graph representation of the data that adheres to the Sankey layout of nodes and links. This transform function is patterned after the work of DensityDesign Lab developers Giorgio Caviglia, Michele Mauri, Giorgio Uboldi, and Matteo Azzi
hides lowest level of graph hierarchy to avoid clutter when all agencies are shown
labels only the top n-percent of nodes on the lowest level of the graph hierarchy to further avoid clutter
I wrote an R script to wrangle, munge, and tidy the data into a CSV file using the tidyverse R package. Connecting to the OMB-hosted data required that I use the RStudio Excel import feature, which produced this code snippet:
url <- "https://www.whitehouse.gov/sites/whitehouse.gov/files/omb/budget/fy2018/state_by_state052417.xls"
destfile <- "state_by_state052417.xls"
download.file(url, destfile)
Updated missing url https://bl.ocks.org/mbostock/raw/5577023/colorbrewer.min.js to /mbostock/5577023/example/colorbrewer.min.js
https://d3js.org/d3.v3.min.js
https://cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.12/crossfilter.min.js
https://cdnjs.cloudflare.com/ajax/libs/dc/2.1.8/dc.min.js
https://bl.ocks.org/mbostock/raw/5577023/colorbrewer.min.js