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:
I worked on that about a year ago. I managed to have parts of HighCharts (SVG graphing in javascript) working with Rhino. I had to plugged env.js into it and ran into a lot of problems regarding canvas Element, especially around Bounding Boxes computations. Objects in Rhino doesn't implement getBBox(), which can't easily be faked.
My goal was to finally render it in PDF with Batik... It took too much time, and we decided to switch to another technology.
So, today, we're using wkhtmltopdf, which is not Java, but which is a static executable that can be embedded in a jar and launched easily from java side. By the way, xvfb is mandatory on Linux if you want to render something. That's pretty the same thing as PhantomJS