XYSeries prob

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
jaypee
Posts: 32
Joined: Fri Mar 24, 2006 2:35 am

XYSeries prob

Post by jaypee » Thu Apr 27, 2006 5:05 am

Hi all,

I have this code for the chart:

Code: Select all

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import org.jfree.data.time.Day;
import java.sql.*;
import java.awt.Dimension;
import ca.edbc.util.EdbcEx;

public class XYSeriesDemo extends ApplicationFrame {

    public XYSeriesDemo(final String title) {

        super(title);
        XYSeries series = new XYSeries("SPC",false,true);

        try {
            Class.forName("ca.edbc.jdbc.EdbcDriver");
            Connection con = DriverManager.getConnection(url,uid,password);
            Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery(sqlSelect);
	        while(rs.next()) {
	        	series.add(new Day(rs.getDate(2)).getMiddleMillisecond(), rs.getInt(1));
	        }
        } catch (NumberFormatException e) {
	        System.err.println("Error adding to series");
        } catch (ClassNotFoundException clex) {
        	//
        } catch (SQLException sqlex) {
        	//
        }

        final XYSeriesCollection data = new XYSeriesCollection(series);
        final JFreeChart chart = ChartFactory.createXYLineChart(
            "XY Series Demo",
            "X",
            "Y",
            data,
            PlotOrientation.VERTICAL,
            true,
            true,
            false
        );

        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new Dimension(800, 570));
        setContentPane(chartPanel);

    }

    public static void main(final String[] args) {

        final XYSeriesDemo demo = new XYSeriesDemo("SPC Chart");
        demo.pack();
        RefineryUtilities.centerFrameOnScreen(demo);
        demo.setVisible(true);

    }

}
but when i run it, it says error adding to series.
what gives? any clue?

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Apr 27, 2006 2:44 pm

Maybe you are getting a NumberFormatException when you read the database...which isn't a JFreeChart problem.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

jaypee
Posts: 32
Joined: Fri Mar 24, 2006 2:35 am

Post by jaypee » Thu Apr 27, 2006 11:26 pm

Hi David,

here are the dates:
2004-10-23
2004-10-23
2004-10-26
2004-10-26
2004-10-26
2004-10-26
2004-10-26
2004-11-03
2004-11-03
2004-11-03
2004-11-03
2004-11-03
2004-11-03
2004-11-03
2004-11-04
2004-11-04
2004-11-05
2004-11-05
2004-11-05
2004-11-06
2004-11-07
2004-11-08
2004-11-09
2004-11-10
2004-11-10
2004-11-11
2004-11-11
2004-11-11
2004-11-11
2004-11-11
2004-11-11
2004-11-11
2004-11-11
2004-11-11
2004-11-13
2004-11-13
2004-11-14
2004-11-14
2004-11-14
2004-11-14
2004-11-14
2004-11-15
2004-11-15
2004-11-15
2004-11-16
2004-11-16
2004-11-16
2004-11-16
2004-11-16
2004-11-16
2004-11-16
2004-11-16
2004-11-16
2004-11-16
2004-11-17
2004-11-18
2004-11-18
2004-11-18
2004-11-18
2004-11-18
2004-11-18
2004-11-18
2004-11-18
2004-11-18
2004-11-18
2004-11-19
2004-11-19
2004-11-26
2004-11-26
2004-11-26
2004-11-26
2004-11-27
2004-11-27
2004-11-29
2004-11-30
2004-11-30
2004-11-30
2004-11-30
2004-11-30
2004-11-30
2004-12-03
2004-12-05
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-08
2004-12-09
2004-12-10
2004-12-10
2004-12-10
2004-12-10
2004-12-10
2004-12-10
2004-12-10
2004-12-10
2004-12-10
2004-12-10
2004-12-11
2004-12-11
2004-12-11
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-13
2004-12-14
2004-12-14
2004-12-15
2004-12-15
2004-12-15

Locked