I would like to use D3.js (or maybe Raphaël) for backend-generated reports using XSL-FO with Java. These JavaScript libraries should be used for several reasons:
- They render more beautiful charts than what I've seen from Java libraries (IMO)
- They support both SVG and PNG (from what I know), which is needed in XSL-FO
- They will also be used in frontend parts of the application. Reusing them also on the backend with Java would reduce developer learning curves and codebase footprint.
So using any similar Java libraries is a less favourable option.
Now the most straight-forward way to use D3.js with Java is to use a heavy tool like selenium in order to render a dummy HTML page and execute the JavaScript in it. But that seems like overkill to me.
Is there any simpler way to execute this kind of JavaScript directly in the same Java process? I'm asking because D3.js is designed to work in the context of an HTML document. I'm not sure if that would be possible to do with Rhino or other Java scripting implementations