简体   繁体   English

混合服务器端java和客户端javascript图表库?

[英]Hybrid server-side-java and client-side-javascript charting library?

Is there a library to generate same charts for the same data, both in Java and Javascript? 是否有一个库可以为Java和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) 在浏览器中显示一些华丽的动态图表,更好地使用动态工具提示,缩放等等(我在想这里的Javascript)
  • 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). 在Java中,在服务器端生成相同(或类似的)图表,以便在电子邮件中自动发送它们(在这种情况下根本没有浏览器)。

I'd like to avoid Flash for iPhone interoperability. 我想避免Flash for iPhone的互操作性。

There are some static server-side charts like Eastwood/JFreeChart, but I'd like to make it more alive in browser. 有一些静态服务器端图表,如Eastwood / JFreeChart,但我想在浏览器中使它更活跃。

Yes I can reload static images via Ajax. 是的我可以通过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! 使用JavaScript,真棒!

Here's your success formula: d3.js + jsdom + Rhino + Batik 这是你的成功公式: d3.js + jsdom + Rhino + Batik

Specifically: 特别:

  1. Generate your graphs using some slick JavaScript library like d3.js . 使用像d3.js这样的光滑JavaScript库生成图形。

  2. Use jsdom to run d3 server-side. 使用jsdom运行d3服务器端。 Jsdom is pure JS library and d3 is known to be working on top of it. Jsdom是纯JS库,已知d3正在处理它。

  3. Run jsdom and d3 inside Rhino - a JavaScript engine baked into your beloved JVM since 1.6 ( yay, JSR-223! ). Rhino中运行jsdom和d3 - 从1.6开始,你的心爱的JVM中引入了一个JavaScript引擎( yay,JSR-223! )。 Although, I suggest you updating it to latest release ( It's on Maven Central, neat! ). 虽然,我建议你把它更新到最新版本( 它是在Maven Central,整洁! )。 I guess Node.JS can do a better job but I assume that you're stuck with Java. 我猜Node.JS可以做得更好,但我认为你已经坚持使用Java了。

    Also note that there's an older, more mature and Rhino-specific server-side DOM implementation - EnvJs ( requires Rhino 1.7R2, not R3 ) . 另请注意,有一个更老,更成熟和特定于Rhino的服务器端DOM实现 - EnvJs 需要Rhino 1.7R2,而不是R3 You can try it if jsdom doesn't work for you. 如果jsdom对你不起作用,你可以尝试一下。

  4. Use Batik to rasterize an SVG generated by d3. 使用Batik光栅化由d3生成的SVG。 Batik even supports scripting inside SVG via Rhino. Batik甚至支持通过Rhino在SVG内部编写脚本。 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. 已知整个方法服务器端工作 ,Node.JS作为JS引擎,ImageMagick作为光栅化器,但我认为没有理由为什么它也不适合你。


BTW, If you'll make it all running let me know. 顺便说一句,如果你能全力以赴,请告诉我。

Pardon the really late reply, but how about using Highcharts ? 原谅真正迟到的回复,但使用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. 我正在寻找能够提供更多信息的链接,因为我输入了这个,但Highcharts提供了服务器端的“导出”功能。 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). 我实现了这个功能,以便我可以接受请求参数,查询数据存储,使用Highcharts将这些数字绘制到所需的图形,并将这些结果嵌入到电子邮件中(当然,将电子邮件发送给收件人)。

More information here: http://www.highcharts.com/component/content/article/2-articles/news/52-serverside-generated-charts 更多信息请访问: http//www.highcharts.com/component/content/article/2-articles/news/52-serverside-generated-charts

AND

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM