JFreeChart,XMLChart,iText等开源报表工具

本文简单介绍JFreeChart,XMLChart,iText等开源报表工具的功能,及如何在Web Application中使用JFreeChart

1.JFreeChart

可以从这里下载:  http://www.jfree.org/jfreechart/index.html 

功能介绍:

JFreeChart is a free Java class library for generating charts, including :
pie charts (2D and 3D);
bar charts (regular and stacked, with an optional 3D effect);
line and area charts;
scatter plots and bubble charts;
time series, high/low/open/close charts and candle stick charts;
combination charts;
Pareto charts;
Gantt charts;
wind plots, meter charts and symbol charts;
wafer map charts;

JFreeChart其他功能:
complete source code is included, under the terms of the GNU Lesser General Public Licence;
access to data from any source via dataset interfaces;
support for multiple secondary axes and datasets;
tooltips, zooming, printing;
direct export to PNG and JPEG;
export to PDF via iText and SVG via Batik (both described in the JFreeChart Developer Guide).
support for servlets, JSP (thanks to Cewolf), applets or client applications;
comprehensive Javadocs;

工作原理:

access to data from any source via dataset interfaces
Generate image file on server side by JfreeChart API
render it on web page by servlet/DisplayChart

 <%
 String sDate = "All";
 Date dDate = null;
 String filename = WebHitChart.generatePieChart(dDate, session, new PrintWriter(out));
 String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
 ArrayList dateList = WebHitDataSet.getDateList();
%>
<table class="table_2_1" width="100%">
<tr>
<td>
 <img src="<%= graphURL %>" width=500 height=300 usemap="#<%= filename %>">
</td>
</tr>
</table>

如何在web application中使用

如果要在jsp中进行显示报表图形。可以把进行数据操作的JAVA文件放到:WEB-INF/src/目录下
要把jfreechart-0.9.20.jar,jcommon-0.9.5.jar放到WEB-INF/lib 目录下
并且在WEB-INF/web.xml中增加:

   <!-- jfree chart servlet -->
   <servlet>
      <servlet-name>DisplayChart</servlet-name>
      <servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
   </servlet>
    <!-- jfree chart servlet mapping -->
 <servlet-mapping>
          <servlet-name>DisplayChart</servlet-name>
          <url-pattern>/servlet/DisplayChart</url-pattern>
  </servlet-mapping>

2.XMLchart

xmlCharts可以方便地根据XML文档中配置和绘制图表。XmlCharts 是用Java开发的,使用了jCharts.
来源: http://sourceforge.net/projects/xmlchart/
现在的版本有中文问题

3.iText

使用iText方便的实现PDF的输出
Resource: http://www.lowagie.com/itext/
JfreeChart chart export to PDF via iText

附:

【Java开源 报表制作】

   转自:  open-open.com

你可能感兴趣的:(servlet,jfreechart,application,报表,dataset,charts)