Day and Hour for XYDataset

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Jim D
Posts: 8
Joined: Wed Sep 10, 2003 6:31 am
Location: Silicon Valley CA
Contact:

Day and Hour for XYDataset

Post by Jim D » Wed Aug 11, 2004 2:34 am

Hi All,

I'm creating a TimeSeries chart with an XYDataset..

I need to have the time value set as both a date and a time.

For example, instead of just saying "Jan 1 2004" I need the time to say something like "Jan 1 2004 12:30"

Is this possible using JFreeChart?

The data I'm displaying have multiple values per day..

Thanks,

Jim

Martin
Posts: 23
Joined: Thu Apr 24, 2003 10:25 am
Location: Germany-Essen

Post by Martin » Wed Aug 11, 2004 3:03 pm

Hi Jim,
it is possible with JFreeChart.
You can change the time period in the constructor towards day, month, quarter, year etc. and add data items to the series depending on the selected time period

This is an example for hourly data:
TimeSeries s1 = new TimeSeries("Name", Hour.class);
int hour=2;
Calendar helpdate = Calendar.getInstance();
helpdate.set(2004,2,2);
s1.add(new Hour(hour, new Day(helpdate)), Price);


Hope this helps
Martin

Jim D
Posts: 8
Joined: Wed Sep 10, 2003 6:31 am
Location: Silicon Valley CA
Contact:

Post by Jim D » Thu Aug 12, 2004 1:47 am

Hi Martin,

Thanks very much for this info.. It seems to be exactly what I'm looking for with one exception.. Looking at the Hour class, there doesn't seem to be a constructor or method that allows one to set the minute as well.

The values I'm adding need to be marked right down to the minute like 02:48 or 16:35 and so on.

Are 'minutes' supported?

Jim

Martin
Posts: 23
Joined: Thu Apr 24, 2003 10:25 am
Location: Germany-Essen

Post by Martin » Fri Aug 13, 2004 3:18 pm

Jim,
check the RegularTimePeriod.class
http://www.jfree.org/jfreechart/javadoc ... eriod.html
In this case the Minute.class fits your needs.

Code: Select all

TimeSeries s1 = new TimeSeries("Name", Minute.class);
int minute=48;
int hour=2;
Calendar helpdate = Calendar.getInstance();
helpdate.set(2004,2,2);
s1.add(new Minute(minute, new Hour(hour, new Day(helpdate))),Price);
Martin

Locked