chart|js|web| Statistics | Graph JSP (Java Server Pages) [1] is a new technology launched by Sun Microsystems in June 1999 and is based on Javaservlet and the entire Java system Web development Technology, This technology can be used to build advanced, secure and Cross-platform Dynamic Web sites. JSP is very similar to Microsoft's ASP (Active Server Pages) technology. Both provide the ability to mix some kind of program code in HTML code, and the language engine to interpret the execution code. In an ASP or JSP environment, HTML code is primarily responsible for describing the display style of information, while program code is used to describe the processing logic. ASP's programming language is VB Script and so on scripting language, and JSP uses Java.
Microsoft? Office Web component [2] first included with Microsoft? Office 2000. Are they ActiveX for adding spreadsheets, charts, and data-processing functionality to a Web page? The collection of controls. Are you using Microsoft? Internet Explorer when browsing Web pages that contain Office Web components, you can work with the displayed data directly in Internet Explorer, such as sorting and filtering data, entering new values, expanding and collapsing detail data, Rotate the rows to see different summaries of the source data, and so on. Microsoft? Office Web controls provide all of these capabilities, and there are three Office Web Components: Spreadsheet components, Chart components, and PivotTable? Component. This article will use the Chart component.
1, JSP technology and chart components
JSP technology is a server-side compilation of the implementation of the Web design language, its scripting language in Java, fully inherits all the Java benefits. It can effectively separate the dynamic part of the Web page from the static part, you just use any kind of familiar web making tools, write the rules of HTML, and then through the JSP tag (tag) [3] will be included in the dynamic part of it, the majority of the tag is "<%" began to "%>" end.
The Chart component is a data-bound ActiveX control used by Microsoft Office to add charting functionality to a Web page. When we install Microsoft Office 2000, we install a component by default the Office Web Components,chart component is included in this component, and the corresponding file is Msowc.dll.
2. Implementation example
The operating environment of this article is: jbuilder7+oracle8i, at the same time using the JavaBean technology to achieve the connection with the Oracle database [4].
The following program graph.jsp realizes the values of diesel locomotives and electric locomotives that are read from the database for a period of time, and then uses a statistical chart to show that the user can choose the graphic mode. (The following Italic section is JSP code)
' Series 0 corresponds to the statistic value of diesel locomotive
Chartspace1.charts (0). SeriesCollection (0). Caption= the legend of "Diesel locomotive statistics" series 0
' To assign the value of diesel locomotive statistics to the array values in VB Script environment
<%
i = 0;
Rs1 = null;
F_FJBM = "";
rs = Zzjwbean.executequery ("SELECT * from T_zzj_dw");
while (Rs.next ())
{
F_FJBM = rs.getstring ("F_FJBM");
Rs1 = Zzjwbean.executequery ("Select sum (F_JC_NRHJ) from t_jccwygk where f_jccwy_fj= '" +f_fjbm+ "' and f_date>= '" +f_gk_ Startdate+ "' and f_date<= '" +f_gk_enddate+ "");/* Statistic Data * *
if (Rs1.next ())
{
%>
VALUES (<%=i%>) =<%=rs1.getint (1)%>
<%
i++;
}
}
%>
' Assign the value of diesel locomotive statistics to the chart series 0
' To assign the value of electric locomotive statistics to the array values in VB Script environment
<%
i = 0;
Rs1 = null;
F_FJBM = "";
rs = Zzjwbean.executequery ("SELECT * from T_zzj_dw");
while (Rs.next ())
{
F_FJBM = rs.getstring ("F_FJBM");
Rs1 = Zzjwbean.executequery ("Select sum (F_JC_DLHJ) from t_jccwygk where f_jccwy_fj= '" +f_fjbm+ "' and f_date>= '" +f_gk_ Startdate+ "' and f_date<= '" +f_gk_enddate+ "");
if (Rs1.next ())
{
%>
VALUES (<%=i%>) =<%=rs1.getint (1)%>
<%
i++;
}
}
%>
' Assign the value of the electric locomotive statistics to the chart series 1
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.