%@ include file="../Includes/DBConn.jsp"%>
<%@ page import="com.fusioncharts.FusionChartsHelper"%>
<%@ page import="java.sql.Statement"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.text.SimpleDateFormat"%>
FusionCharts Free - Database and Drill-Down Example
<%
/*You need to include the following JS file, if you intend to embed the chart using JavaScript.
Embedding using JavaScripts avoids the "Click to Activate..." issue in Internet Explorer
When you make your own charts, make sure that the path to this JS file is correct. Else, you would get JavaScript errors.
*/
%>
Detailed report for the factory
<%
/*This page is invoked from Default.jsp. When the user clicks on a pie
slice in Default.jsp, the factory Id is passed to this page. We need
to get that factory id, get the information from database and then show
a detailed chart.
*/
//First, get the factory Id
String factoryId=null;
//Request the factory Id from parameters
factoryId = request.getParameter("FactoryId");
String chartCode="";
if(null!=factoryId){
// we will use the FusionChartsHelper class for colors
FusionChartsHelper colorHelper= new FusionChartsHelper();
ResultSet rs=null;
String strQuery;
Statement st=null;
java.sql.Date date=null;
java.util.Date uDate=null;
String uDateStr="";
String quantity="";
String strXML="";
//Generate the chart element string
strXML = "";
//Now, we get the data for that factory
strQuery = "select * from Factory_Output where FactoryId=" +factoryId;
st=oConn.createStatement();
rs = st.executeQuery(strQuery);
while(rs.next()){
date=rs.getDate("DatePro");
quantity=rs.getString("Quantity");
if(date!=null) {
uDate=new java.util.Date(date.getTime());
// Format the date so that the displayed date is easy to read
SimpleDateFormat sdf=new SimpleDateFormat("d/M");
uDateStr=sdf.format(uDate);
}
strXML += "";
}
//Close element
strXML +="";
//close resultset,statement,connection
try {
if(null!=rs){
rs.close();
rs=null;
}
}catch(java.sql.SQLException e){
//do something
System.out.println("Could not close the resultset");
}
try {
if(null!=st) {
st.close();
st=null;
}
}catch(java.sql.SQLException e){
//do something
System.out.println("Could not close the statement");
}
try {
if(null!=oConn) {
oConn.close();
oConn=null;
}
}catch(java.sql.SQLException e){
//do something
System.out.println("Could not close the connection");
}
//Create the chart - Column 2D Chart with data from strXML
%>
<% }
%>
Back to Summary
Unable to see the chart above?