In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to use Java to output statistical charts on the Web page" related knowledge, editor through the actual case to show you the process of operation, the method of operation is simple and fast, practical, I hope that this "how to use Java to output statistical charts on the Web page" article can help you solve the problem.
In the application of Inte.NET and Intranet, the combination of database and Web technology is the key to transplant traditional MIS system to Internet (Intrant) environment. Many manufacturers have launched their own products, but these products basically realize the output of data in html format. In practical applications, we often need to show the data in the form of statistical graphs, such as the output of stock market graphs. The traditional method is to put the statistical chart as a graphic file in the directory of the Web server. Although this method is simple, it has obvious limitations: first, the graphic file needs to occupy a large storage space; second, it is difficult to adapt to the flexible and complex query requirements; third, the graphic file is updated with the change of the database, which increases the burden on the server. it is also easy to cause inconsistency between graphics and database.
Obviously, to achieve the above requirements, we need two key links: one is to read the data from the database; the other is to draw in the Web page according to the read data. We use JdbC to access the database, and the drawing in the Web page is implemented using the Graphics class provided in the Java.awt package.
For ease of expression, the data sheet is established as follows:
Item
Index mark
Aquaculture
sixty
Process management
eighty-nine
Drought resistance and flood prevention
one hundred
Financial affairs
two hundred
Office
three hundred and fifty
Survey meter
eighty
Our goal is to show the above table as a statistical chart (horizontal bar chart is used in this article). The databases referred to in this article are all tables in the above form, field 1 is a character field, which represents project information, and field 2 is a numeric field (read out with a floating point), indicating the number of indicators. In practical application, a little modification of the program can make it more flexible and universal.
To draw various forms of diagrams, first define a Graph abstract class (note not Graphics):
Import java.sql. *
Import java.awt. *
Abstract class Graph {
Height and width of the int height,width; / / drawing area
Int maxRow=50,row=0
/ / the maximum number of records and the number of actual records that can be held
Color color=new Color (5050200); / / default drawing color
Float scale; / / scale
String [] name; / / Project name buffer
Float [] value; / / indicator value buffer
Public Graph (Dimension djinint maxRows,Color fColor) {
Height=d.height
Width=d.width
Name=new String [maxRows]
Value=new float [maxRows]
Color=fColor
}
Public void setResult (ResultSet result)
{/ / read query results into buffer
Try {
Row=0
While (result.next () & & row
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.