1

Ok so im using netbeans to create a form that takes user input then puts this data on to a ms access file using a simple sql statement. My class objective is to retrieve the data and show it on the console using this piece of code:

    s.execute("SELECT * FROM DOGS");

    ResultSet rs = s.getResultSet();         

    if (rs != null) 
    while ( rs.next() )       {

    System.out.println("Dog Information: Name: " + rs.getString(1)  + " Breed: " 
    +rs.getString (2) +" Age: "+rs.getString(3)
    +" Neutered: "+rs.getString(4));
    }

All dandy so far. But now what I would like to try is to output the data as a graph on another jform. The data is simple enough, just citys and sales numbers. What I want to ask is if someone could nudge me in the right direction of how to go about turning data into a graph?

javawocky
  • 899
  • 2
  • 9
  • 31

1 Answers1

2

Could you explain it a little please?

In outline,

  1. Download JFreechart.

  2. Study the examples of basic chart types mentioned here.

  3. Given a Connection conn, create a dataset.

    JDBCXYDataset jds = new JDBCXYDataset(conn);
    jds.executeQuery("select attribute from DOGS");
    
  4. Use the dataset to create the desired chart.

    JFreeChart chart = ChartFactory.createDesiredChart(…, jds, …);
    
  5. Add the chart to your top-level container.

    frame.add(new ChartPanel(chart));
    
Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • You'll have to decide what actual `ChartFactory` to use. Please edit your question to include an [sscce](http://sscce.org/) that exhibits any problem you encounter. – trashgod Oct 15 '13 at 16:42