Created
September 9, 2015 13:00
-
-
Save ashgillman/150331a78a3c34727e8b to your computer and use it in GitHub Desktop.
Static D3 Visualisation
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
{ | |
"name": "Static-D3-Visualisation", | |
"version": "1.0.0", | |
"description": "Template to make visualisations with D3 locally", | |
"dependencies": { | |
"jsdom": "^3.1.2" | |
}, | |
"devDependencies": { | |
"coffee-script": "^1.10.0" | |
}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Ashley Gillman", | |
"license": "MIT" | |
} |
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
#!/usr/bin/sh | |
npm install | |
./node_modules/.bin/coffee -c visualisation.coffee | |
node visualisation.js > visualisation.svg | |
convert visualisation.svg visualisation.png |
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
jsdom = require 'jsdom' | |
jsdom.env '<html><body></body></html>', | |
[ 'http://d3js.org/d3.v3.min.js' ], | |
(err, window) -> | |
svg = window.d3.select 'body' | |
.append 'svg' | |
.attr 'width', 100 | |
.attr 'height', 100 | |
svg.append 'rect' | |
.attr 'x', 10 | |
.attr 'y', 10 | |
.attr 'width', 80 | |
.attr 'height', 80 | |
.style 'fill', 'orange' | |
console.log(window.d3.select("body").html()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment