Hybrid server-side-java and client-side-javascript charting library?
Asked Answered
F

2

4

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?

Fabien answered 15/4, 2011 at 13:32 Comment(2)
What about Flot? Unfortunately you'd have to render to a canvas in a browser to export it. You could combine it with JFreeChart/Eastwood and have two graphs from the same data, although they'd look different.Trouveur
See also #11331576Oscillogram
V
8

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:

  1. Generate your graphs using some slick JavaScript library like d3.js.

  2. Use jsdom to run d3 server-side. Jsdom is pure JS library and d3 is known to be working on top of it.

  3. 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 (requires Rhino 1.7R2, not R3). You can try it if jsdom doesn't work for you.

  4. 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.

The whole approach is known to work server-side with Node.JS as a JS engine and ImageMagick as a rasterizer but I see no reasons why it wouldn't work for you as well.


BTW, If you'll make it all running let me know.

Vice answered 27/5, 2012 at 20:52 Comment(3)
Great answer, thank you! A pity I'm no longer on Grails project at all, this could be fun. "If you'll make it all running let me know." :DFabien
Letting you know: #24557808Classify
Wow! This is not "somewhat hardcore": it's 100% hardcore!Oscillogram
H
2

Pardon the really late reply, but how about using Highcharts? I'm looking for the link which provides you more information as I'm typing this, but Highcharts provides a server-side 'export' feature. What it basically does is it allows you to download a copy of an image without actually requiring a browser.

I implemented this feature so that I could take take request parameters, query a data-store, plot those numbers using Highcharts to a desired graph and embed those results in an email (and of course, send the email out to the recipients).

More information here: http://www.highcharts.com/component/content/article/2-articles/news/52-serverside-generated-charts

AND

here: https://github.com/one2team/highcharts-serverside-export

Heywood answered 5/11, 2014 at 2:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.