hye...
i have data from sqlserver which i want to insert into the graph...
the graph should display one day graph that contains about 144 data...
thats mean the data is every 10 minute....
the graph is generate to JPEG
the problem is
D:\javae>java GraphTest
enter data
TimeSeries.add(): you are trying to add data where the time period class is org.jfree.data.time.Minute, but the TimeSeries is expecting an instance of org.jfree.data.time.Day.
Using: org.jfree.chart.encoders.SunJPEGEncoderAdapter
output jpeg >>>>>>>>>>>0
supposedly it should got>>>> 144...
this is the coding....
maybe sumone can help me to solve it.....
import java.awt.Dimension;
import javax.swing.JPanel;
import org.jfree.chart.*;
import org.jfree.data.time.*;
import org.jfree.data.xy.XYDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.swing.*;
import java.sql.*;
public class GraphTest //extends ApplicationFrame
{
public static void main(String args[])
{
int month = 12;
int i = 0;
double bufferHeight;
ResultSet rsTide = null;
XYDataset xydataset;
TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
TimeSeries timeseries1 = new TimeSeries("Wind Speed");
TimeSeries timeseries2 = new TimeSeries("Wind Gust");
JFreeChart jfreechart = null;
try
{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conTide = null;
conTide = DriverManager.getConnection("jdbc:odbc:Westport","wnidba","wnisql");
Statement sttTide = conTide.createStatement();
rsTide = sttTide.executeQuery("SELECT * FROM WindParameters");
}
catch(Exception e){ System.out.println(e.getMessage()); }
try
{
while(rsTide.next() && i <= 144)
{
Hour hour = new Hour();
System.out.println("enter data");
bufferHeight = Double.parseDouble(""+rsTide.getString("Speed600s"));
timeseries1.add(new Minute(i, hour), bufferHeight);
//timeseries1.add(new Minute(i,0,1, month, 2004),bufferHeight );
//bufferHeight = Double.parseDouble(""+rsTide.getString("Speed3s"));
//timeseries2.add(new Minute(i,0,1, month, 2004),bufferHeight );
System.out.println("finish data");
i++;
}
}
catch(Exception f){ System.out.println(f.getMessage()); }
try
{
timeseriescollection.addSeries(timeseries1);
timeseriescollection.addSeries(timeseries2);
xydataset = timeseriescollection;
jfreechart = ChartFactory.createTimeSeriesChart( "Tide Parameters(Daily)", "Minute", "Meter", xydataset, true, false, false);
}
catch(Exception e){ System.out.println(e.getMessage()); }
try
{ ChartUtilities.saveChartAsJPEG(new java.io.File("dbGraph"+i+".jpg"), jfreechart, 600, 200);
System.out.println("output jpeg >>>>>>>>>>>"+i);}
catch (java.io.IOException exc)
{ System.out.println(exc.getMessage()); }
//timeseries1 = null;
//timeseries2 = null;
//xydataset = null;
}
}