This gist is mostly based on Tom Pearson's Block but with a slightly clearer use of d3 with the window object provided by jsdom's 'done' function. This example works as expected but perhaps there are some subtleties that I have missed in Tom's approach.
Other examples of using D3 and jsdom can be found in the tests straight from the D3 github
To use this example, open a command-prompt/terminal and
cd /directory/containing/package.json
npm install