Originally published on my old blog, April 2017.
This example runs with d3.v2, an older version.
It's based on a tutorial from Jeff Fletcher on his South Africa dataviz blog, Limn. He bundles up the appropriate versions of cartogram, topojson and d3 here.
And in my own Github repo, here's how I knitted all this together.
Data source: Population estimate for July, 2016 from the U.S. Census, downloaded April 25, 2017.