D3 v4 is modular, based on around 30 "microlibraries", intended to allow discrete functions to be broken out and used on their own.

I'm trying to assemble a minimal set of D3 microlibraries to do the following:

  • Asynchronously load a TopoJSON file from the server using .json function
  • Process this data
  • Using a projection, turn it into a SVG polygon or path definition strings (not SVG elements)

...and that's it. I'm using something else (Raphael.js) to process the path strings, so I don't need the rest of D3.

I thought I'd only need topojson and d3.geo but I'm either not understanding something or I'm lacking the capability to load JSON files and the capability to convert data to path definitions, and I'm struggling to find those features in the D3 micro-libraries.

1 Answer 1


I asked about a related D3 problem on StackOverflow and the answer to that also included enough info to answer this.

Loading JSON files with d3.json() requires:

  • d3-request
  • d3-dispatch
  • d3-collection

TopoJSON files, if used, need to be unpacked into GeoJSON with topojson( json, json.features.someLayer ) which requires:

  • topojson.js (technically not a D3 micro-library but by the same publisher and on the same github account)

Applying a projection and then generating path strings using var geopath = d3.geoPath().projection() and geoPath( geojsonData ) requires:

  • d3-geo
  • d3-array

This involves no actual DOM manipulation or actual SVG elements, and simply allows text strings of SVG path definitions to be generated - any actual DOM manipulation is likely to require d3-select and more.

It's worth mentioning that all the above appear to be compatible with Internet Explorer 8 so long as polyfills such as es5.js are used for various Object related functions. So, the above can be used with something like Raphael.js for IE8 compatibility.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.