Is there a library to generate same charts for the same data, both in Java and Javascript?
My task is both:
display some flashy dynamic chart in a browser, better with dynamic tooltips, zooming and so on (I'm thinking Javascript here)
and generate the same (or similar enough) charts on server side, in Java, for automatically sending them in emails (no browser at all in this scenario).
I'd like to avoid Flash for iPhone interoperability.
There are some static server-side charts like Eastwood/JFreeChart, but I'd like to make it more alive in browser.
Yes I can reload static images via Ajax. Are there other options?
解决方案
How come this question is more than a year old but got no answers?! I suggest a rather questionable and somewhat hardcore approach.
Use JavaScript, it's awesome!
Here's your success formula: d3.js+jsdom+Rhino+Batik
Specifically:
Generate your graphs using some slick JavaScript library like d3.js.
Use jsdom to run d3 server-side. Jsdom is pure JS library and d3 is known to be working on top of it.
Run jsdom and d3 inside Rhino - a JavaScript engine baked into your beloved JVM since 1.6 (yay, JSR-223!). Although, I suggest you updating it to latest release (It's on Maven Central, neat!). I guess Node.JS can do a better job but I assume that you're stuck with Java.
Also note that there's an older, more mature and Rhino-specific server-side DOM implementation - EnvJs
Use Batik to rasterize an SVG generated by d3. Batik even supports scripting inside SVG via Rhino. That means you can generate interactive charts server-side if you want to. I also used it in practice and had great experience with it.
BTW, If you'll make it all running let me know.