How to generate time series chart from JDBC data?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
laredotornado
Posts: 3
Joined: Wed Nov 03, 2004 8:28 pm

How to generate time series chart from JDBC data?

Post by laredotornado » Thu Nov 04, 2004 4:23 pm

Hi,
I'm having trouble compiling a bit of code. I want to generate a time series chart from some a JDBCXYDataset. The code is below:


JDBCXYDataset lineDataSet = null;
Connection con;
try {
con = DBDaemon.getConnection(sPool);
lineDataSet = new JDBCXYDataset(con);
lineDataSet.executeQuery(sQuery);
con.close();
}
catch (SQLException e) {
System.err.print("SQLException: ");
System.err.println(e.getMessage());
throw new RuntimeException(e.getMessage());
}
catch (Exception e) {
System.err.print("Exception: ");
System.err.println(e.getMessage());
throw new RuntimeException(e.getMessage());
}

chart = ChartFactory.createTimeSeriesChart
(sTitle, // Title
sDomainLabel, // Domain access label
sRangeLabel, // Range access label
lineDataSet, // Dataset
PlotOrientation.VERTICAL, // Plot Orientation
true, //legend
true, // tooltips
false
);

and this is the compile error I get:

JDBCLineChartServlet.java:84: createTimeSeriesChart(java.lang.String,java.lang.String,java.lang.String,org.jfree.data.xy.XYDataset,boolean,boolean,boolean) in org.jfree.chart.ChartFactory cannot be applied to (java.lang.String,java.lang.String,java.lang.String,org.jfree.data.jdbc.JDBCXYDataset,org.jfree.chart.plot.PlotOrientation,boolean,boolean,boolean)
chart = ChartFactory.createTimeSeriesChart

What to do?

lrebyc
Posts: 6
Joined: Sat Oct 30, 2004 6:38 am

Post by lrebyc » Fri Nov 05, 2004 10:56 am

Hi,

I did not try out your code. I think it shoud work with explicit casting your
lineDataSet into XYDataset


[...]
chart = ChartFactory.createTimeSeriesChart
(sTitle, // Title
sDomainLabel, // Domain access label
sRangeLabel, // Range access label
(XYDataset) lineDataSet, // Dataset
PlotOrientation.VERTICAL, // Plot Orientation
true, //legend
true, // tooltips
false);

Locked