Home Answers Viewqa Java-Beginners JFreeChart dosn't work

 
 


Frank Kofoed Myhre
JFreeChart dosn't work
0 Answer(s)      a year and 2 months ago
Posted in : Java Beginners

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









Related Pages:
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
jfreechart
jfreechart  hi how install jfreechart? and how free download jcommon? plz insert link for this? thanks   Hi Friend, Please visit the following link: Download JFreechart Download jfreechart-1.0.13.zip from the given
JFreechart & JCommon
JFreechart & JCommon   hi........... thanks a lot. The code is running successfully and able to get the output. Thanks once again
Error in JfreeChart
Error in JfreeChart  I am getting an error when i am using jfreechart for graph generation, that is: D:\my\linechart.java:5: package org.jfree.chart... and download the jfreechart api: http://www.brothersoft.com/jfreechart
Error in JfreeChart
Error in JfreeChart  I am getting an error when i am using jfreechart for graph generation, that is: D:\my\linechart.java:5: package org.jfree.chart does not exist import org.jfree.chart.*; what is the reason and possible
JFreeChart- Display coordinate value .
JFreeChart- Display coordinate value .  How to Mark Coordinte value on top of the bar
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 zoomin and zoomout - Framework
Jfreechart zoomin and zoomout  how to zoomin and zoom out chart using button plus and minus or slide bar in jFree chart
Jfreechart - Java Beginners
Jfreechart  Hi Team, Am very new to Jfreechart concept. And I was tried to configure Jfreechart in my system but I cant. Can any one pls guide me how to install and configure JFreechart from the basic with the necessary files
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
Jfreechart chart display problem
Jfreechart chart display problem  Using JSP and Jfreechart displays the chart fine on an internal browser in eclipse but doesnt display it on Chrome..."); dataset.executeQuery(query); JFreeChart chart = ChartFactory.createLineChart
Jfreechart setting Legends - Java Beginners
Jfreechart setting Legends  Hi... i am using JfreeChart in my web app. for creating charts.I am trying to make the legends as vertical in Stacked bar chart. Does anybody know How to set the legends in any graph as vertical
Class files for Jfreechart - JSP-Servlet
Class files for Jfreechart  Respected Sir/Madam, I am Ragavendran.R.. I have downloaded Jfreechart 1.0.13 in my system for performing..... Regards, Ragavendran.R..  Hi Friend, Jar file Jfreechart 1.0.13
jvm work
jvm work  wht is the work of jvm? deaply.   Hi Friend, Java Virtual Machine or JVM for short is a software execution engine to run the java programs. Java Virtual Machine is also known as "Java Interpreter" which
Graphs using JFreeChart - Java Beginners
(); dataset.addSeries(s1); dataset.setDomainIsPointsInTime(true); JFreeChart
Create Histogram using Jfreechart
Create Histogram using Jfreechart In this section, you will learn how to create histogram using jfreechart. To create a Histogram, we have used the class  HistogramDataset. Then method addSeries()  allows to add the series
How to display jfreechart at specified place in jsp
How to display jfreechart at specified place in jsp  I have a jsp page where i need to display the chart at specified position...("Inet", 20); JFreeChart chart = ChartFactory.createPieChart3D
jfreechart display from access database data.
jfreechart display from access database data.  I have made a database... the bar graph using jfreechart API .This whole retrieval and display of chart...", "sun.jdbc.odbc.JdbcOdbcDriver","root","root"); dataset.executeQuery(query); JFreeChart chart
JFreechart Stacked Bar Chart
JFreechart Stacked Bar Chart JFreechart provides a way to create various... JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new..."); result.addValue(32, "Boys", "Hockey"); return result; } private JFreeChart
validator framework work in Struts
validator framework work in Struts  How does validator framework work in Struts
Message Resource Bundle work.
Message Resource Bundle work.  How does Value replacement in Message Resource Bundle work
JFreechart multi line chart help in JSP
JFreechart multi line chart help in JSP  Hi, I am am looking for and help in getting multi line chart with Jfree chart, i had manage to write..."); dataset.executeQuery(query); //(final XYDataset dataset){ final JFreeChart chart
how formBackingObject() method will work.
how formBackingObject() method will work.  How the formBackingObject method will behave
collection frame work
collection frame work  explain all the concept in collection frame work
jfreechart displaying chart from access database
jfreechart displaying chart from access database  I have these 2... "Short description"; }// </editor-fold> } and a jfreechart file..."); JFreeChart chart = ChartFactory.createBarChart("MARKS INFORMATION
work - JSP-Servlet
JSP Work Directory   What is the absolute path for the JSP working directory
validate() method of ActionForm work
validate() method of ActionForm work  How does validate() method of ActionForm work
collection frame work
collection frame work  explain the hierarchy of one dimensional collection frame work classes
collection frame work
collection frame work  could you please tell me detail the concept of collection frame work
How to work with Ajax in spring
How to work with Ajax in spring  give some sample code for ajax with spring (example like if i select a state from one drop down in another drop down related districts should come
ios work with nsdictionary
ios work with nsdictionary  How to work with NSDictionary in Objective C?   Working with NSDictionary in Objective C Basically, in Objective C NSDictionary is used to create and retrive the Key values for objectecs
Stacked Bar Chart using JFreeChart
Stacked Bar Chart using JFreeChart       This Example shows you how to create a Stacked bar chart using JFreeChart. In the code given below we have extended class
How to display Jfreechart from servlet in jsp web page at specified location
How to display Jfreechart from servlet in jsp web page at specified location  Hello Sir, I am developing a demo project in which i need to display the chart in web page. I generated the chart using Jfreechart
how to show x axis values of timeline chart in jfreechart with particular month.
how to show x axis values of timeline chart in jfreechart with particular month.  my x-axix timeline having day of 1 month and days shows me only differently and 1 month. I want month attached with days
sing validator framework work in struts
sing validator framework work in struts  How does client side validation using validator framework work in struts
which tags work on which browsers
which tags work on which browsers  Is there a site that shows which tags work on which browsers
spring MVC frame work - Spring
spring MVC frame work  Example of spring MVC frame work
Create a polar chart using JFreeChart
Create a polar chart using JFreeChart       This Example shows you how to create a polar chart using JFreeChart. Code given below creates a simple polar chart
graph generation using jfreechart and retrieving values from the database
graph generation using jfreechart and retrieving values from the database ... jfreechart API .This whole retrieval and display of chart is to be done in a servlet...", "sun.jdbc.odbc.JdbcOdbcDriver","root","root"); dataset.executeQuery(query); JFreeChart chart
how to show value and percentage in piechart sections from database using jfreechart
JFreeChart setup and the basic servlet * configuration. * * @param...(query); JFreeChart chart = ChartFactory.createPieChart("Call
How java work on Unicode machanish
How java work on Unicode machanish   How the data are stored in java as unicode, how the conversions is done for input/output stream. Please describe in detail with memory aspect
Restlet Frame work Related question
Restlet Frame work Related question  How to send data from client to server using Restlet framework. The main problem is i am not able to get data at server side. Can anyone post a complete program how to achieve
Jquery form validation does not work
effect does not work. Could you please solve this problem? Thanks!   

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.