简体   繁体   English

MySQL和Java Web应用程序的图表

[英]Charts with MySQL and Java Web Application

I've been looking through examples online about charting libraries to work with in a Java Web Application but they all keep trying to implement some form of php to get the data before the chart is produced. 我一直在网上浏览有关在Java Web应用程序中使用图表库的示例,但是它们都一直在尝试实现某种形式的php以在生成图表之前获取数据。

Ideally I would like to use google charts and then take data from my database through jsp/ servlet of some sort but I can't find any examples online without php. 理想情况下,我想使用Google图表,然后通过某种jsp / servlet从数据库中获取数据,但是如果没有php,我将找不到任何在线示例。

I've tried Jfreechart but again can't find much documentation. 我已经尝试过Jfreechart,但再次找不到太多文档。

question I'm trying to ask is, How would I be able to draw charts that get data from MySQL and display them on my web page. 我想问的问题是,如何绘制从MySQL获取数据的图表并将其显示在我的网页上。 All this is in Netbeans currently. 目前,所有这些都在Netbeans中。

Thanks in advance, 提前致谢,

Rather than using jsp/servlets, have you considered using Java Server Faces? 您是否考虑过使用Java Server Faces,而不是使用jsp / servlets? You can find an explanation of the differences here . 您可以在此处找到差异的解释。

If you were to use Java Server Faces, you would then be able to use PrimeFaces Charts to create something like this: 如果要使用Java Server Faces,则可以使用PrimeFaces Charts创建如下内容:

PrimeFaces图表

You can see a full set of examples at the PrimeFaces website, and there is a tutorial on creating Generating a JavaServer Faces 2 Application here that covers creating an appplication lined to a MySQL database. 你可以看到全套的PrimeFaces网站的例子,并且对创建生成JavaServer教程面临2应用在这里覆盖内衬创建到MySQL数据库的应用项目。

Using this method, you would place the chart data inside a bean and then reference it (the bean) from your webpage. 使用此方法,您可以将图表数据放置在bean中,然后从您的网页中引用它(bean)。

If you want to use JFreeChart, you can use ChartUtilities#saveChartAsXXXX to save an image of the chart on the server and then include a link to the the generated image inside your webpage. 如果要使用JFreeChart,则可以使用ChartUtilities#saveChartAsXXXX将图表图像保存在服务器上,然后在网页中包含指向生成的图像的链接。

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

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