Created
December 22, 2011 20:40
-
-
Save mattbaker/1511770 to your computer and use it in GitHub Desktop.
Build a pie chart using d3.js and send the result to stdout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* jsdomtest.js: Build a pie chart using d3.js and send the result to stdout | |
* Requires d3.js and d3.layout.js in same directory | |
* Requires pie.js from this gist: https://gist.github.com/1509145 | |
* ex. node jsdomtest.js > pie.svg | |
*/ | |
var jsdom = require('jsdom'), | |
scripts = ["file://"+__dirname+"/d3.min.js", | |
"file://"+__dirname+"/d3.layout.min.js", | |
"file://"+__dirname+"/pie.js"], | |
htmlStub = '<!DOCTYPE html><div id="pie" style="width:'+400+'px;height:'+400+'px;"></div>'; | |
jsdom.env({features:{QuerySelector:true}, html:htmlStub, scripts:scripts, done:function(errors, window) { | |
var svgsrc = window.insertPie("#pie", 400, 400, [0.25,0.25,0.5]).innerHTML; | |
console.log(svgsrc); | |
}}); |
Great! Glad to hear it. I updated the other gist with the small http server as well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh. Thanks. I try the code you newly committed. It's ok now. Thank you.