Generate charts and graphs from the command line using d3 and PhantomJS.
Install playfair with
npm install -g playfair
Then, you can render SVG graphics from JavaScript (produced using d3 or any other library with facilities for SVG drawing) with the command:
playfair <myfile.html>.
By default, playfair saves SVG output to a file named output.svg
. You can redirect this output with the -o --output
option:
playfair index.html --output example.svg
By default, playfair retrieves the first SVG element from the document. You can pass in an id with the -i --id
option:
playfair index.html --id example-id
This will extract the first matching SVG node from the document using document.querySelector("svg#example-id")
.