Is there a way to plot data like the following:
12/03/03 12:25:32 500,000
14/03/03 17:52:44 622,000
19/03/03 09:29:02 450,002
So it is data that has exact points and inconsistent time gaps between points but is part of the same series.
I am current plotting it with the "TimePeriod" class which means the above the data is represented and displayed like:
between 12/03/03 12:25:00 and 12/03/03 12:26:00 500,000
between 14/03/03 17:52:00 and 14/03/03 17:53:00 622,000
between 19/03/03 09:29:00 and 19/03/03 09:30:00 450,002
or even worse, having 1 hour intervals to reduce number of points
between 12/03/03 12:00:00 and 12/03/03 13:00:00 500,000
between 14/03/03 17:00:00 and 14/03/03 18:00:00 622,000
between 19/03/03 09:00:00 and 19/03/03 10:00:00 450,002
timePeriod = new Hour(data.getDateValue(), TimeZone.getTimeZone("Etc/Zulu"));
series.add(timePeriod, data.getValue());
This is okay, but not as accurate as I would like. Am I going about it the wrong way?
TimeSeries graphs
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Use a TimePeriod subclass that is the smallest unit where you are certain there will only be one observation. It looks to me like you should use the Second class. If you can have more than one observation per second, then use the Millisecond class.
You create a TimeSeries that represents your data and add it to a TimeSeriesCollection (because this class implements the XYDataset interface). Now, when the TimeSeriesCollection needs to return an X value for plotting, it can choose from the start, middle or end of the time period associated with each of your Y-values. Use the setPosition(...) method to specify which you want. Note that this is changing to setXPosition(...) in the 0.9.11 release - the old method will be deprecated.
You create a TimeSeries that represents your data and add it to a TimeSeriesCollection (because this class implements the XYDataset interface). Now, when the TimeSeriesCollection needs to return an X value for plotting, it can choose from the start, middle or end of the time period associated with each of your Y-values. Use the setPosition(...) method to specify which you want. Note that this is changing to setXPosition(...) in the 0.9.11 release - the old method will be deprecated.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

