Some simple, frequently used functions for creating a map with D3.js and Topojson.
This block also uses the libraries chroma and jeezy.
centerZoom - Automatically centers and scales your map to its container, and returns your map's outer boundaries in case you want to draw them.drawOuterBoundary - Uses the boundary returned from centerZoom to draw a boundary around your whole map.drawPlaces - Draws place names, if your topojson has places.drawSubunits - Draws subunits.fillSubUnits - Fills subunits according to specified limits and color scale.drawTip - Draws and positions and tooltip based on the data of the selected subunit.drawLegend - Draws a legend according to specified limits and color scale.See this tutorial for more on making maps with D3. I got most of the centerZoom function from this block.
https://d3js.org/d3.v4.min.js
https://unpkg.com/d3-moveto@0.0.3/build/d3-moveto.js
https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.20/topojson.min.js
https://unpkg.com/jeezy@1.12.0/lib/jeezy.min.js
https://cdnjs.cloudflare.com/ajax/libs/chroma-js/1.3.4/chroma.min.js