JFreeChart dosn't work

Ads
 

JFreeChart dosn't work

Hello everybody

I'm trying to make a line chart from JFreechart, but I just can't get it to work. The graph get its data from at 2-columun database (String, double). (The string is a date, represented as a String). The X-axis should be the different string, and the Y-axis should be the double values. I tried DefaultCategoryDataset, but every time I run it, an error occurs (i tried an example from here, with XY, and it didn't work either)

I could really use some help on this, as i'm completely lost. (It has been checked that the database contains the data)

public class Chart {

    Connection conn;
    Statement stmt;
    ResultSet rs;

    Chart(){
        try{
            Class.forName("org.sqlite.JDBC");
            conn = DriverManager.getConnection("jdbc:sqlite:projectdb.db");
            System.out.println("Database connection established");
            String dateinput;
            double temp;

            DefaultCategoryDataset dataset = new DefaultCategoryDataset();


            stmt = conn.createStatement();
            rs = stmt.executeQuery("SELECT * FROM data");
            while(rs.next()){
                dateinput = rs.getString(1);
                temp = rs.getDouble(2);
                dataset.addValue(temp, "", dateinput);
            }

            JFreeChart chart = ChartFactory.createLineChart(null,
                                                            "Time",
                                                            "Temperature",
                                                            dataset,
                                                            PlotOrientation.VERTICAL,
                                                            true,
                                                            true,
                                                            false);

            JFrame test = new JFrame();
            test.setVisible(true);

            ChartPanel chpanel = new ChartPanel(chart);
            chpanel.setPreferredSize(new Dimension(785, 440));
            chpanel.setMouseWheelEnabled(true);
            JPanel panel = new JPanel();
            panel.add(chpanel);
            test.add(panel);


        }
        catch(Exception e){
            System.out.println(e.getMessage());
        }        
    }
    public static void main(String[] args){
        new Chart();

        }
}
View Answers

Ads









Related Tutorials/Questions & Answers:
JFreeChart dosn't work
JFreeChart dosn't work  Hello everybody I'm trying to make a line chart from JFreechart, but I just can't get it to work. The graph get its data... it, an error occurs (i tried an example from here, with XY, and it didn't work either) I
Version of jfreechart>jfreechart dependency
List of Version of jfreechart>jfreechart dependency
Advertisements
JFreechart & JCommon
JFreechart & JCommon   hi........... thanks a lot. The code is running successfully and able to get the output. Thanks once again
Artifacts of jfreechart
List of Artifacts of jfreechart maven depenency
jfreechart
jfreechart maven dependency
jfreechart maven dependency  Hi, I want to use jfreechart library in my Java project. My project is maven based and I am trying to find the maven dependency of jfreechart. What is jfreechart maven dependency? Thanks
Version of jfree>jfreechart dependency
List of Version of jfree>jfreechart dependency
Maven Dependency jfreechart >> 0.9.16
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.16 in your project
Maven Dependency jfreechart >> 0.9.17
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.17 in your project
Maven Dependency jfreechart >> 0.9.18
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.18 in your project
Maven Dependency jfreechart >> 0.9.19
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.19 in your project
Maven Dependency jfreechart >> 0.9.2
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.2 in your project
Maven Dependency jfreechart >> 0.9.20
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.20 in your project
Maven Dependency jfreechart >> 0.9.3
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.3 in your project
Maven Dependency jfreechart >> 0.9.8
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.8 in your project
Maven Dependency jfreechart >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version1.0.0 in your project
JFreeChart - An Introduction
JFreeChart - An Introduction       JFreeChart is a free open source java chart library. David Gilbert founded the JFreeChart project in February 2000. Now a days
how to install jfreechart in netbeans.
how to install jfreechart in netbeans.  I have successfully installed jfreechart in eclipse IDE.but I am unable to install the same in netbeansIDE 6.7.1 .There is some error regarding the ant folder.Please tell the step by step
JFreeChart Tutorial
JFreeChart Tutorials, examples and articles The JFreeChart is Java based.... In this tutorial we teach you to use popular JFreeChart api for creating various... for generating dynamic graphs from Java based applications. The JFreeChart
Line Graph using JFreeChart
Line Graph using JFreeChart  I need to draw a line graph of the (no. of sales made on y axis) by a shop with (dates on x axis) using data from MySQL database and JFreeChart
Version of jfree>jfreechart-experimental dependency
List of Version of jfree>jfreechart-experimental dependency
Version of jfree>jfreechart-swt dependency
List of Version of jfree>jfreechart-swt dependency
Line Graph using JFreeChart
Line Graph using JFreeChart  I need to draw a line graph of the (no. of sales made on y axis) by a shop with (dates on x axis) using data from MySQL database and JFreeChart. DRIVER: com.mysql.jdbc.Driver URL: jdbc:mysql
Line Graph using JFreeChart
Line Graph using JFreeChart  I need to draw a line graph of the (no. of sales made on y axis) by a shop with (dates on x axis) using data from MySQL database and JFreeChart. DRIVER: com.mysql.jdbc.Driver URL: jdbc:mysql
utiliser jfreechart dans portlet struts
utiliser jfreechart dans portlet struts  Bonjour. J'ai un pfe,et mon application m'impose d'utiliser jfreechart,je trouve juste la documentation de jfreechart avec struts2 seulement,mai je l'ai besoin ds un portlet liferay. vu ke
Using JFreeChart to display recent changes in a time series
Using JFreeChart to display recent changes in a time series  Using JFreeChart to display recent changes in a time series
Jfreechart chart display problem
Jfreechart chart display problem  Using JSP and Jfreechart displays...(request.getParameter("q")); String query="select dateof,dayinprice,company from stockprice..."); dataset.executeQuery(query); JFreeChart chart = ChartFactory.createLineChart
Maven Dependency jfreechart >> 0.9.21
You should include the dependency code given in this page to add Maven Dependency of jfree >> jfreechart version0.9.21 in your project
Maven Dependency jfreechart >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of jfree >> jfreechart version1.0.0 in your project
Maven Dependency jfreechart >> 1.0.0-rc1
You should include the dependency code given in this page to add Maven Dependency of jfree >> jfreechart version1.0.0-rc1 in your project
Maven Dependency jfreechart >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of jfree >> jfreechart version1.0.1 in your project

Ads