by david.gilbert » Thu Mar 27, 2008 3:01 pm
For the chart, you'll want an XYPlot with a DateAxis for the domain axis (X axis), and a NumberAxis for the range axis (Y axis). Most likely you'll want the renderer to be an XYLineAndShapeRenderer. That's the basic setup for what we describe as a "time series" chart.
You have a few different options for the dataset. JFreeChart has the classes TimeSeries and TimeSeriesCollection which are convenient for defining time-based datasets, but if you are just taking millisecond date stamps from the database, then you may not need some of the overhead of those classes. In that case, you could simply populate a regular XYSeries and add it to an XYSeriesCollection, or alternatively use the DefaultXYDataset class.
The important thing to remember with the time series charts is that the x-values are still just numbers, representing milliseconds since 1-Jan-1970, but they appear on the chart as dates because the DateAxis class provides date labels in place of the numerical values. You probably already understand that, but it is surprising how many people don't see the relationship so I thought I'd mention it anyway.