###Creating static data visualizations with D3.js and Node.js###
See the accompanying blog post for more details on how to create static data viz using D3.js and Node.js
Re-creates Mike Bostock's area choropleth example for Node.js. Allows for output/creation of a non-interactive SVG via the command line.
Requires Node.js and npm. You will also need D3.js for Node.js, installed via,
npm install d3
Command line usage (outputs area_choropleth.svg):
node area_choropleth.js > area_choropleth.svg
Example output (png converted from svg)
This example recreates a visualization using the following data and JS packages:
- us.json - US county data (created by Mike Bostock)
- topojson client API - converts Topojson to Geojson
- D3.js - JavaScript library for manipulating documents based on data
Hi,
I always got error as bellow:
-> % node area_choropleth.js > area_choropleth.svg
/Users/ple/an/genSVG/node_modules/d3/d3.js:562
return n.querySelector(s);
^
TypeError: Cannot read property 'querySelector' of undefined
at d3_select (/Users/ple/an/genSVG/node_modules/d3/d3.js:562:13)
at Object.d3.select (/Users/ple/an/genSVG/node_modules/d3/d3.js:1043:17)
at Object. (/Users/ple/an/genSVG/area_choropleth.js:24:14)
at Module._compile (module.js:426:26)
at Object.Module._extensions..js (module.js:444:10)
at Module.load (module.js:351:32)
at Function.Module._load (module.js:306:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:117:18)
at node.js:946:3
I think we need something as jsdom http://stackoverflow.com/questions/19080929/d3js-how-to-generate-standalone-svg-files-nodejs.
Let me know if I did something wrong.
Thanks,