开发者

Hybrid server-side-java and client-side-javascript charting library?

开发者 https://www.devze.com 2023-02-25 06:41 出处:网络
Is there a library to generate same charts for the same data, both in Java and Javascript? My task is both:

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, b开发者_如何学JAVAut 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:

  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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消