I need to add some infographics into Angular 5 app. I've chosen d3.js for that. I also need to be able to do export of graphs, i.e. make SVGs with Node and wrap them inside PDF.
Fortunately it's rather simple to make code that makes d3 graph in browser work on node.js. The following lines do that...
const { JSDOM } = jsdom;
const { window } = new JSDOM();
const { document } = (new JSDOM('')).window;
global.document = document;
After that only minor changes to code that works in browser are required.
Obviously I don't want to have 2 copies of almost the same code, so I need a way to organize usage of the functions that create SVG (I'd preffered if that was typescript not javascript) on both angular app side and node app side. Unfortunatelly I don't have to much expirience in Node and don't see an easy solution for that.
Here are my questions...
- How can I simply organize usage of fuctions that create SVG using d3 by angular 5 app and node.js app?
- Maybe rendering d3.js with node is't a best solution and there's another, that is simplier?
Thank you in advance!
from d3.js: run the same code in Angular app and on node.js
No comments:
Post a Comment