0

I created a graph with connection to the database as follows:

String s = jTSensor.getText();
String query="select date, dew_point from records where idSensor like '"+s+"'";
JDBCCategoryDataset dataset = new JDBCCategoryDataset (
    CriaConexao.getConexao(),query);
JFreeChart chart = ChartFactory.createLineChart(
    "Records", "Date", "Dew Point", dataset, 
    PlotOrientation.VERTICAL, false, true, true);
BarRenderer renderer = null;
CategoryPlot plot= null;
renderer=new BarRenderer();
ChartFrame frame = new ChartFrame("Records", chart);
frame.setVisible(true);
frame.setSize(400,650);

But only gives a line to show. I wish it was possible to seek other data to the database and show the results with other lines, but I'm not succeeding. Someone can help me please.

Greetings

tangens
  • 39,095
  • 19
  • 120
  • 139
strange_098
  • 1,261
  • 6
  • 24
  • 44
  • "[NOTE](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/data/jdbc/JDBCCategoryDataset.html): Many people have found this class too restrictive in general use. For the greatest flexibility, please consider writing your own code to read data from a ResultSet and populate a `DefaultCategoryDataset` directly." – trashgod Feb 18 '14 at 09:35

1 Answers1

1

Look at How to display line graph using JFreeChart in jsp? and build your solution around createXYLineChart. For database access there is already a JDBCXYDataset. XYDataset supports multiple series of data while the CategoryDataset you are useing does not (as far as I know).

Community
  • 1
  • 1
wumpz
  • 8,257
  • 3
  • 30
  • 25