Create a web-based chart with Jfreechart

Source: Internet
Author: User
Tags requires

The development of WWW makes internet-based applications no longer limited to static or simple dynamic content delivery. Traditional software packages, such as reporting systems, are gradually moving to the Internet. But there is a big difference between the two, although the data acquisition, business processing, and so on are basically similar, but the biggest differences in the user interface. In order to display data in a Web browser that requires the user interface to use HTML as well as pictures, the traditional user interface developed using the operating system's own controls cannot adapt to a dazzling array of clients and therefore becomes powerless here.

To get back to the title of this article, there are two ways to create a chart that you can view on a Web browser: the first is to use the applet to display a graph using Java's own support for graphics, and the second is to send a chart picture file directly to the browser on the Web server side. The first approach is obviously too high for the client, and as the mainstream browser now abandons its support for Java, this approach is only suitable for some local area network applications, and the Internet environment is not very appropriate. So we'll introduce a Java diagram engine Jfreechart to produce web-based charts.

Introduction of Jfreechart Project

Jfreechart is a Java project on the open source site SourceForge.net, which is used primarily for a wide variety of charts, including pie, histogram (plain column and stack bar), line, area, distribution, blending, Gantt Chart and some dashboard and so on. These different patterns of graphs can basically meet the current requirements. In order to reduce the length this article mainly introduces the previous three kinds of charts, readers can analogy to develop other styles of charts. The following are the results of these three types of charts produced by Jfreechart:

Figure 1

Figure 2

Figure 3

The three graphs above are sales information for a product that represents four quarters. The development environment must be prepared before continuing with the following section, because it is based on a Web browser chart presentation and therefore requires a servlet engine or a Java EE application server (such as WEBSPHERE,TOMCAT, etc.). The construction of the Web environment is not cumbersome, the reader according to the preferences of their own installation. The Jfreechart engine itself needs to be downloaded to the SourceForge.net address as follows:

Jfreechart Home: http://www.jfree.org/jfreechart/index.html

Jfreechart download page: http://sourceforge.net/projects/jfreechart/

When downloading, note that you must download two files: Jfreechart and Jcommon. At present, the latest matching version is: Jfreechart 0.9.11 Jcommon 0.8.6

Here are some of the problems that I have encountered in development: When using Eclipse development, you will report a puzzling error that may point to the first line of a class file. This problem is generally due to the fact that the Jcommon jar package is not set to the project's classpath. The exact cause is ominous. (and log4j and so on are also bitten together to import).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.