Vote count:
0
Given a JS script running a D3js dynamic dataviz
I currently print out a single view into a output.svg
file using :
var jsdom = require('jsdom');
jsdom.env(
"<html><body></body></html>", // CREATE DOM HOOK:
[ 'http://ift.tt/JmLP3T', // JS DEPENDENCIES online ...
'js/d3.v3.min.js' ], // ... & offline
// D3JS CODE * * * * * * * * * * * * * * * * * * * * * * * *
function (err, window) {
var svg = window.d3.select("body")
.append("svg") // append svg on body
... // more D3js code
// END svg design
//PRINTING OUT SELECTION
console.log(window.d3.select("body").html());
}
// END (D3JS) * * * * * * * * * * * * * * * * * * * * * * * *
);
Terminal NodeJS command :
node svgcreator.node.js > output.svg
The way it works is that each console.log()
message from svgcreator.node.js
script is printed into the file output.svg
file.
Since this D3js dataviz turn around the globe, I should be possible to print out one console.log()
message for each view into a proper svg file named correctly. I thing I should get a variable such var country=...;
from the JS script up to the terminal. Then, I could do (?) something such :
node svgcreator.node.js > $(JsVar.country).svg
So whenever a console.log() message come, the message in printed into an SVG file with the correct name.
Also, how to pass JS variable's value from script to terminal ?
See also: Node.js : how to pass parameter's value from terminal to JS script
Node.js : how to pass JS variable's value from script to terminal?
Aucun commentaire:
Enregistrer un commentaire