1

The data I am trying to represent in my charts will usually be shown with timestamps (dates and times) going along the bottom, or x axis, and a variety of data (which will always be simple integers or maybe float data in the future) shown on the left axis. Basically it will be mapping events along the bottom, and say, performance along the left.

I am using JFreeChart, however unfortunately the support for developers is non-existent, and I will not be paying for their tutorials. Straight away I can see many chart types which I could use, this post is asking for the most suitable collection and chart object for me to use.

Originally I went for XYDataSet with XYScatterPlot, but I realise one of the axes must be a date, not a simple integer. So I just had a look at TimeSeries and TimeSeriesChart objects. However for some odd reason it only seems to allow boolean or float (not integer values on the number axis). Also it's saying my Timestamp class is deprecated (all the date information I am using is stored in an object database as timestamps, storing year, month, day, hour, minute, second etc.).

So in summary, I want the best collection and chart object to store a simple series of graphs mapping a timestamp date to integer values. Cheers.

dahui
  • 2,128
  • 2
  • 21
  • 40

1 Answers1

4

While I recommend the guide for professional developers, students and afficionados will want to examine the extant examples and source. org.jfree.chart.demo.TimeSeriesChartDemo1, included in the distribution, is particularly relevant to your use case, and the associated createTimeSeriesChart() methods of ChartFactory show how such a chart is constructed using a DateAxis.

Disclaimer: Not affiliated with Object Refinery Limited; just a satisfied customer and very minor contributor.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • I have already seen the example, I just want to know how to work with Timestamp objects. – dahui Feb 16 '14 at 22:45
  • `JDBCXYDataset`, cited [here](http://stackoverflow.com/a/15997548/230513), is a good example of a dataset designed for this. – trashgod Feb 16 '14 at 23:08
  • I will check it out! I've sorted my problem now, it turns out I can throw a Timestamp object straight into the Dataset for the date axis, and it works. Thank you for your answer and the links. – dahui Feb 19 '14 at 11:56
  • Right, they use milliseconds from the same epoch; see also `setDateFormatOverride()`, illustrated [here](http://stackoverflow.com/a/2723103/230513). – trashgod Feb 19 '14 at 14:40