<% / ** * This page is mainly used to show the temperature graph in a certain date of a gas station. * Time: 2005-04-18 * @Author: Iraqi * @version 1.0 * /%> <% @ Page Contenttype = "text / html; charset = GBK"%> <% @ page import = "java.awt.color, java.awt.font, java.io. *, java.sql. *, java.sql.resultset, Java.sql.ResultSetMetadata, java.util.arraylist, java.util. *, org.jfree.chart.chartfactory, Org.jfree.chart.chartPanel, Org.jfree.chart.jfreechart, org.jfree.chart.servlet. ServletUtilities, Org.jfree.chart. *, Org.jfree.chart.axis.axisspace, Org.jfree.Chart.StandardLegend, Org.jfree.chart.axis.dateaxis, Org.jfree.Chart.plot.xyplot, ORG. JFree.Chart.Renderer.standardxyitemrenderer, org.jfree.chart.renderer.xyitemrenderer, Org.jfree.data.xydataset, org.jfree.data.time. Hour, org.jfree.data.time.minute, org.jfree.data.time.day, org.jfree.data.time.timeseries, org. JFree.Data.Time.TimeSeriesCollection "%> <% string welid = request.getParameter (" Wellid "); // Take the Well number of the query String Transtime = Request.GetParameter (" Transtime "); // Take the query Date String Para = Request.GetParameter ("para"); // Take the parameter of the query Class.Forname ("com.microsoft.jdbc.sqlser.sqlserverdriver"); string url = "JDBC: Microsoft: SQLServer: // localhost : 1433; DatabaseName = MIS "; // MIS is the database name String user =" sa ";
// user name String password = ""; // user password Connection conn = DriverManager.getConnection (url, user, password); Statement stmt = conn.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); int i = 0; int J = 0; Double [] row = new double [144]; day days = new day (); // generate a day to generate 24 hours of the day TimeSeries S1 = New TimeSeries ("输 气 站 wellid " " Transtime " Para, Minute.Class); for (j = 0; j <24; j ) {// respectively values each hour, 6 int m = 0 per hour; string SQL = "SELECT" Para ", Transtime From Trans_gas Where (VARCHAR (10), TRANSTIME, 20) = '" TRANSTIME ") and (Wellid ='" Wellid ")" "and ({Fn Hour (Transtime)} = " J ") "; ResultSet RS = Stmt.executeQuery (SQL); While (rs.next () && m <6) {row [6 * j m] = rs.getdouble (1) Rs.next (); i ; m ;} if (m <6) {// If there is no 6 values within this hour, fill in 0 for (int K = m; k <6; k ) {row [6 * J K] = 0;}} Hour Hour = new Hour (j, days); s1.add (new minute (0, hour), row [6 * j]); s1.add (new minute (10, Hour, row [6 * j 1]); S1.Add (New Mi Nute (20, hour), row [6 * j 2]); S1.Add (New Minute (30, Hour), ROW [6 * J 3]); S1.Add (New Minute (40, Hour) , Row [6 * J 4]); S1.Add (New Minute (50, Hour), Row [6 * J 5]);} TimeSeriesCollection DataSet = New TimeSeriesCollection (); Dataset.Addseries (S1);
DataSet.SetDomainispointsintime (TRUE); JFreeChart Chart = ChartFactory.createtimeSerieschart ("输 气" Wellid " Transtime " Para "Towing Map", "Time", Para "Valize", True, true, false ); // chart.setbackgroundpaint (color.white);
StandardLegend SL = (StandardLegend) Chart.getlegend (); sl.setdisplayseriesshapes (TRUE);
XYPLOT PLOT = chart.getxyplot (); Plot.setBackground (new color (136, 189, 193)); // Set background color Plot.SetDomainGridlinePaint (color.White); // Set grid vertical line color Plot.SetRangeGridlinePaint (color.White) ; // Set the grid horizontal color //Plot.setDomainTickBandPaint (New Color (33, 66, 99)); // Setting the segment block color //plot.setfixeddomainAXISSPACE (NEW axisspace ()); // Pack the fixed axis blank XYItemRenderer renderer = plot.getRenderer (); if (renderer instanceof StandardXYItemRenderer) {StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setPlotShapes (true); // true value for each draw a small square rr.setShapesFilled (true); // True means filled each small square}
Dateaxis axis = (dateaxis) Plot.getdomainaxis ();
String filename = ServletUtilities.saveChartAsPNG (chart, 1024, 600, null, session); String graphURL = request.getContextPath () "? / Servlet / DisplayChart filename =" filename;%> 转载请注明原文地址:https://www.9cbs.com/read-34825.html